注销不会在laravel socialite中注销

时间:2018-03-14 09:26:13

标签: laravel-socialite laravel-5.6

我无法在我的应用程序中注销谷歌用户,当我注销它重定向登录页面说它已成功注销但当我点击登录时使用谷歌按钮它重定向到以前登录的用户,即它不是退出

我的控制器代码

class LoginController extends Controller {
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/

use AuthenticatesUsers;

/**
 * Where to redirect users after login.
 *
 * @var string
 */
protected $redirectTo = '/home';

/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct() {
    $this->middleware('guest')->except('logout','getLogout');
}

/**
 * Redirect the user to the GitHub authentication page.
 *
 * @return \Illuminate\Http\Response
 */
public function redirectToProvider() {
    return Socialite::driver('google')->redirect();
}

/**
 * Obtain the user information from GitHub.
 *
 * @return \Illuminate\Http\Response
 */
public function handleProviderCallback() {
    $user = Socialite::driver('google')->stateless()->user();
    if($user) {
        $authUser = $this->findOrCreateUser($user);

        Auth::login($authUser, true);
    }
    return view ( 'home' )->withDetails ( $user )->withService ( 'google' );
    // $user->token;
}

/**
 * Return user if exists; create and return if doesn't
 *
 * @param $githubUser
 * @return User
 */
private function findOrCreateUser($googleUser) {
    if ($authUser = User::where('email', $googleUser->email)->first()) {
        return $authUser;
    }
    return User::create([
        'name' => $googleUser->name,
        'email' => $googleUser->email, 
    ]);
}}

我已经按照laravel文档步骤进行此社交登录,但我无法从我的应用程序注销。任何人都可以解释为什么会发生这种情况?

1 个答案:

答案 0 :(得分:0)

好吧,最后我找到了我的问题的解决方案。实际上,没有什么可担心的。登出代码工作得很好.Google帐户要求获得授权访问后首次登录的权限它不会要求许可它直接继续登录。如果我们退出谷歌帐户,那么它将要求许可,否则它将不会