您好,我正在使用 Laravel Socialite 通過我的遠程 Laravel Paspport 應用程序進行 Oauth 身份驗證。成功使用護照對用戶進行身份驗證后,當我想讓用戶訪問應用程序時,它會將我重定向回登錄狀態并在他注銷時執行操作??蛻舳耍⊿ocialite 在此 git https://gitlab.fit.cvut.cz/ouredma3/trackage上)我嘗試在設置中切換域,但沒有任何效果。在我實施 Oauth 之前它運行良好。我使用 Socialite 與https://socialiteproviders.netlify.app/providers/laravel-passport.html 我希望它是你所需要的一切,但如果有什么讓我知道,我將添加更多信息 Laravel 7.x,PHP 7.2這是我的登錄控制器。 public function redirectToProvider() { return Socialite::driver('laravelpassport')->redirect(); } /** * Obtain the user information from Passport * * @return \Illuminate\Http\Response */ public function handleProviderCallback(Request $request) { try { $userSocial = Socialite::driver('laravelpassport')->stateless()->user(); } catch (\Exception $e) { return redirect('/login')->withError($e->getMessage()); } $users = User::where(['email' => $userSocial->getEmail()])->first(); if($users){ Auth::login($users,true); }else{ $user = User::create([ 'email' => $userSocial->getEmail(), 'provider_id' => $userSocial->getId() ]); Auth::login($user,true); } //session(['current_user' => $userSocial]); return redirect('/'); }
添加回答
舉報
0/150
提交
取消