Laravel自定义基本身份验证 - 仅用户名

时间:2015-11-02 11:49:08

标签: php laravel

我创建了一个自定义基本身份验证,弹出一个请求用户名和密码的身份验证页面。但是在用我的路线把它挂起之后,它就不起作用了。

这是auth类

namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Routing\Middleware;

class SxroAuthenticateWithBasicAuth implements Middleware
{
  /**
     * The Guard implementation.
     *
     * @var Guard
     */
    protected $auth;

    /**
     * Create a new filter instance.
     *
     * @param  Guard $auth
     */
    public function __construct(Guard $auth)
    {
        $this->auth = $auth;
    }
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        return $this->auth->basic('username') ?: $next($request);
    }
}

我想登录username而不是email,所以我相信我做对了。但为什么不工作?

我得到了像这样的内核设置

'auth.sxro' => \App\Http\Middleware\SxroAuthenticateWithBasicAuth::class,

输入用户名和密码时。

enter image description here

它不会起作用,并且不断弹出。有人告诉我发生了什么事吗?我该怎么调试呢?

0 个答案:

没有答案