X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a76599bd2aaf85040b67b3ce2f64e6ea88961936..refs/pull/1462/head:/app/Auth/Access/SocialAuthService.php diff --git a/app/Auth/Access/SocialAuthService.php b/app/Auth/Access/SocialAuthService.php index 024a1e736..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,10 +52,7 @@ class SocialAuthService public function startRegister($socialDriver) { $driver = $this->validateDriver($socialDriver); - if ($socialDriver == 'google') { - return $this->socialite->driver($driver)->with(['prompt' => 'select_account'])->redirect(); - } - return $this->socialite->driver($driver)->redirect(); + return $this->getSocialDriver($driver)->redirect(); } /** @@ -250,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; + } }