我正在尝试制作自定义防护并且我成功了,但是当我尝试使用防护登录时
$this->attemptLogin($request)返回true,但之后直接Auth::check()返回该方法false
/**
* Handle a login request to the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function login(Request $request)
{
$this->validateLogin($request);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
if (method_exists($this, 'hasTooManyLoginAttempts') &&
$this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
if ($this->attemptLogin($request)) { // Returns true
dd(Auth::check()); // Returns false
return $this->sendLoginResponse($request);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
$this->incrementLoginAttempts($request);
return $this->sendFailedLoginResponse($request);
}
使用的模型扩展Illuminate\Foundation\Auth\User
我还覆盖了该getAuthPassword方法,因为您使用access_code
我还在使用中定义$guard并为它做了一个保护auth.phpsession as the driver
我读过类似的问题,但他们建议应该调用 PKid和 be auto_increment。
我确实满足这些条件。
我还覆盖了guardLoginController 中的方法,它包含该use AuthenticatesUsers;行
我正在使用 Laravel 6.5.1 版
我也没有收到错误。
皈依舞
不负相思意