diff --git a/.env.example b/.env.example index eda20ea26..6e015335e 100644 --- a/.env.example +++ b/.env.example @@ -48,6 +48,7 @@ GITHUB_APP_ID=false GITHUB_APP_SECRET=false GOOGLE_APP_ID=false GOOGLE_APP_SECRET=false +GOOGLE_SELECT_ACCOUNT=false OKTA_BASE_URL=false OKTA_APP_ID=false OKTA_APP_SECRET=false diff --git a/app/Auth/Access/SocialAuthService.php b/app/Auth/Access/SocialAuthService.php index 87db1d5c6..66f567c98 100644 --- a/app/Auth/Access/SocialAuthService.php +++ b/app/Auth/Access/SocialAuthService.php @@ -40,7 +40,7 @@ class SocialAuthService public function startLogIn($socialDriver) { $driver = $this->validateDriver($socialDriver); - return $this->socialite->driver($driver)->redirect(); + return $this->redirectToSocialProvider($driver)->redirect(); } /** @@ -52,7 +52,7 @@ class SocialAuthService public function startRegister($socialDriver) { $driver = $this->validateDriver($socialDriver); - return $this->socialite->driver($driver)->redirect(); + return $this->redirectToSocialProvider($driver)->redirect(); } /** @@ -247,4 +247,18 @@ class SocialAuthService session()->flash('success', trans('settings.users_social_disconnected', ['socialAccount' => title_case($socialDriver)])); return redirect(user()->getEditUrl()); } + + /** + * Provide redirect options per service for the Laravel Socialite driver + * @param $driver + */ + public function redirectToSocialProvider($driver) + { + if ($driver == 'google' && config('services.google.select_account')) + { + return $this->socialite->driver($driver)->with(['prompt' => 'select_account']); + } + + return $this->socialite->driver($driver); + } } diff --git a/config/services.php b/config/services.php index 711040386..857a7caa2 100644 --- a/config/services.php +++ b/config/services.php @@ -59,6 +59,7 @@ return [ 'name' => 'Google', 'auto_register' => env('GOOGLE_AUTO_REGISTER', false), 'auto_confirm' => env('GOOGLE_AUTO_CONFIRM_EMAIL', false), + 'select_account' => env('GOOGLE_SELECT_ACCOUNT', false), ], 'slack' => [