]> BookStack Code Mirror - bookstack/blobdiff - app/Auth/Access/SocialAuthService.php
Update maintenance.php
[bookstack] / app / Auth / Access / SocialAuthService.php
index a9adec93eb5ddac37581f2a61c0e7dd279d956ce..0d46b9f882d5ebe6afe1d08fb0d7b4714c9eeb74 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->getSocialDriver($driver)->redirect();
     }
 
     /**
@@ -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->getSocialDriver($driver)->redirect();
     }
 
     /**
@@ -253,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;
+    }
 }