亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

登錄嘗試成功后 Auth::check() 返回 false

登錄嘗試成功后 Auth::check() 返回 false

PHP
海綿寶寶撒 2022-06-17 10:14:34
我正在嘗試制作自定義防護并且我成功了,但是當我嘗試使用防護登錄時$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 版我也沒有收到錯誤。
查看完整描述

2 回答

?
皈依舞

TA貢獻1851條經驗 獲得超3個贊

您的默認守衛是web. 當您在Auth::...未指定守衛的情況下調用時,它將使用默認守衛。

在您LoginController中,您正在定義要用作方法的contestant防護的防護guard。你需要檢查那個守衛而不是網絡守衛。您可以使用從該方法返回的守衛來檢查,而不是Auth::check()

dd($this->guard()->check());


查看完整回答
反對 回復 2022-06-17
?
不負相思意

TA貢獻1777條經驗 獲得超10個贊

不知道你是否還需要這個,但我剛剛發現問題是系統不知道在哪里存儲會話。就像我的情況一樣,它發生在我嘗試進行某種單點登錄時。所以你需要做的是改變

SESSION_DRIVER=file to SESSION_DRIVER=database

然后運行

php artisan session:table


查看完整回答
反對 回復 2022-06-17
  • 2 回答
  • 0 關注
  • 120 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號