Php 拉维尔社交名流不';我不能在谷歌浏览器上工作

Php 拉维尔社交名流不';我不能在谷歌浏览器上工作,php,laravel,google-chrome,laravel-6,laravel-socialite,Php,Laravel,Google Chrome,Laravel 6,Laravel Socialite,我对Laravel社交名媛的登录有一个问题,我的Chrome正常工作,但其他人的浏览器不工作(在其他浏览器中工作)。在服务器中的php从7.1更新到7.3.18以及从5.8更新到Laravel6之前,所有这些都正常工作。我尝试清除所有缓存,将会话模式更改为cookie(之前的文件),清除浏览器中的会话和cookie,但没有解决问题 这是我的代码: public function loginSocial(Request $request){ $this->validate($req

我对Laravel社交名媛的登录有一个问题,我的Chrome正常工作,但其他人的浏览器不工作(在其他浏览器中工作)。在服务器中的php从7.1更新到7.3.18以及从5.8更新到Laravel6之前,所有这些都正常工作。我尝试清除所有缓存,将会话模式更改为cookie(之前的文件),清除浏览器中的会话和cookie,但没有解决问题

这是我的代码:

public function loginSocial(Request $request){
    $this->validate($request, [
        'social_type' => 'required|in:google,facebook'
    ]);
    $socialType = $request->get('social_type');
    return Socialite::driver($socialType)->stateless()->redirect();
}

public function loginCallback(Request $request){
    $socialType = $request->session()->get('social_type');
    //Aparently, this get give to $socialType null in ppl browser. I dont understand why this get doesn't works.
    $userSocial = Socialite::driver($socialType)->stateless()->user();
    //If use 'google' instead $socialType, works fine.
    $user = User::where('email',$userSocial->email)->first();
    \Auth::login($user);
    return redirect()->intended($this->redirectPath());
}

我明白你想做什么,但有时少就是多,多就是少。。。。。回拨是由提供商而不是用户进行的。无论如何,每个社交登录都有不同的方法

// Google login
public function googleSocialLogin(Request $request){
    Socialite::driver('google')->stateless()->redirect();
}

// Google callback
public function googleSocialLoginCallback(){

    $userSocial = Socialite::driver('google')->stateless()->user();
    $user = User::where('email',$userSocial->email)->first();

    \Auth::login($user);
    return redirect()->intended($this->redirectPath());
}

// Facebook login
public function facebookSocialLogin(Request $request){
    Socialite::driver('facebook')->stateless()->redirect();
}

// Facebook callback
public function facebookSocialLoginCallback(){

    $userSocial = Socialite::driver('facebook')->stateless()->user();
    $user = User::where('email',$userSocial->email)->first();

    \Auth::login($user);
    return redirect()->intended($this->redirectPath());
}
将方法分开后,您将有不同的社交登录路由,IMO更好,因为它们的返回参数略有不同,并且您可能希望在将来为特定的社交登录执行附加功能