Forcing user account selection for Laravel Socialite Google+ logins

北城以北 提交于 2020-05-11 12:57:37

问题


I recently implemented Laravel Socialite so that users can login using their Google+ accounts. Everything seems to be working but one issue I'm having is that after I login for the first time in a browser I am unable to switch to a different Google account if I log out and then log back in. Once the following code is executed in the LoginController it automatically (all in one action) logs me in with my Google account and redirects me back to my site without giving me the option to choose a different Google account.

public function redirectToProvider()
{
    return Socialite::driver('google')->redirect();
}

Is there a way to force the user to explicitly choose which account they wish to login with every time?


回答1:


A parameter "select_account" should be added to prompt for choosing the account before login. in your case it can be like below:

public function redirectToProvider()
{
   return Socialite::driver('google')->with(["prompt" => "select_account"])->redirect();
}

This worked for me.



来源:https://stackoverflow.com/questions/48571507/forcing-user-account-selection-for-laravel-socialite-google-logins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!