Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing user account selection for Laravel Socialite Google+ logins

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?

like image 313
Brian Lewis Avatar asked Feb 01 '18 20:02

Brian Lewis


1 Answers

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.

like image 134
Kulshreshth K Avatar answered Nov 07 '22 09:11

Kulshreshth K