From: Justin Stein Date: Sun, 4 Nov 2018 18:40:06 +0000 (-0800) Subject: Added function for redirect with parameters for Socialite X-Git-Tag: v0.24.2~3^2~2^2~4 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/0283ab11b5f675037dd1634993c5e794edc142ad Added function for redirect with parameters for Socialite --- diff --git a/app/Auth/Access/SocialAuthService.php b/app/Auth/Access/SocialAuthService.php index a9adec93e..79f6bbd0f 100644 --- a/app/Auth/Access/SocialAuthService.php +++ b/app/Auth/Access/SocialAuthService.php @@ -40,10 +40,7 @@ class SocialAuthService public function startLogIn($socialDriver) { $driver = $this->validateDriver($socialDriver); - if ($socialDriver == 'google' && env('GOOGLE_SELECT_ACCOUNT')) { - return $this->socialite->driver($driver)->with(['prompt' => 'select_account'])->redirect(); - } - return $this->socialite->driver($driver)->redirect(); + return $this->redirectToSocialProvider($driver); } /** @@ -55,10 +52,7 @@ class SocialAuthService public function startRegister($socialDriver) { $driver = $this->validateDriver($socialDriver); - if ($socialDriver == 'google' && env('GOOGLE_SELECT_ACCOUNT')) { - return $this->socialite->driver($driver)->with(['prompt' => 'select_account'])->redirect(); - } - return $this->socialite->driver($driver)->redirect(); + return $this->redirectToSocialProvider($driver); } /** @@ -253,4 +247,19 @@ 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 + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function redirectToSocialProvider($driver) + { + if ($driver == 'google' && config('services.google.select_account')) + { + return $this->socialite->driver($driver)->with(['prompt' => 'select_account'])->redirect(); + } + + return $this->socialite->driver($driver)->redirect(); + } }