我在项目中使用社交名媛。它在当地环境下运行良好,但是当我切换到生产环境时,它已经无法正常工作了。使用谷歌登录会将我重新导回到谷歌的“登录”页面。我已经更新了google api设置中的回调网址。请帮忙
public function handleProviderCallback($provider)
{
try
{
$socialUser = Socialite::driver($provider)->user();
}
catch (\Exception $e)
{
return back()->withErrors([
'socialConnectionError', 'An error has occured while connecting to '.$provider.' service'
]);
}
$socialProvider = SocialProvider::where('provider_id', $socialUser->getId())->first();
if (! $socialProvider) {
$user = User::firstOrCreate([
'is_activated' => 1,
'email' => $socialUser->getEmail(),
'name' => $socialUser->getName()
]);
// still needs to implement the system where a user may change its name and email on social provider
$user->socialProviders()->create(
['provider_id' => $socialUser->getId(),
'provider' => $provider]
);
}
else
{
$user = $socialProvider->user;
}
auth()->login($user);
return redirect($this->redirectPath());
}
public function redirectToProvider($provider)
{
return Socialite::driver($provider)->redirect();
}