]> BookStack Code Mirror - bookstack/commitdiff
Added function for redirect with parameters for Socialite
authorJustin Stein <redacted>
Sun, 4 Nov 2018 18:40:06 +0000 (10:40 -0800)
committerJustin Stein <redacted>
Sun, 4 Nov 2018 18:40:06 +0000 (10:40 -0800)
app/Auth/Access/SocialAuthService.php

index a9adec93eb5ddac37581f2a61c0e7dd279d956ce..79f6bbd0f7138e3187a4891a935e7d0813c6eabc 100644 (file)
@@ -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();
+    }
 }