X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/257a5a23ecaf7ce779969d575ff8a0b976181d13..refs/pull/1462/head:/app/Auth/Access/SocialAuthService.php diff --git a/app/Auth/Access/SocialAuthService.php b/app/Auth/Access/SocialAuthService.php index 87db1d5c6..0d46b9f88 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->getSocialDriver($driver)->redirect(); } /** @@ -52,7 +52,7 @@ class SocialAuthService public function startRegister($socialDriver) { $driver = $this->validateDriver($socialDriver); - return $this->socialite->driver($driver)->redirect(); + return $this->getSocialDriver($driver)->redirect(); } /** @@ -247,4 +247,20 @@ 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 $driverName + * @return \Laravel\Socialite\Contracts\Provider + */ + public function getSocialDriver(string $driverName) + { + $driver = $this->socialite->driver($driverName); + + if ($driverName === 'google' && config('services.google.select_account')) { + $driver->with(['prompt' => 'select_account']); + } + + return $driver; + } }