您好,我正在使用 Laravel Socialite 通过我的远程 Laravel Paspport 应用程序进行 Oauth 身份验证。成功使用护照对用户进行身份验证后,当我想让用户访问应用程序时,它会将我重定向回登录状态并在他注销时执行操作。客户端(Socialite 在此 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('/');
}
holdtom