]> BookStack Code Mirror - bookstack/commitdiff
Merge pull request #1063 from justein230/master
authorDan Brown <redacted>
Sat, 10 Nov 2018 14:32:28 +0000 (14:32 +0000)
committerGitHub <redacted>
Sat, 10 Nov 2018 14:32:28 +0000 (14:32 +0000)
Add select account parameter for google authorization

.env.example
app/Auth/Access/SocialAuthService.php
config/services.php

index eda20ea261bb9147a17dd451877fc42b5896311f..6e015335efa711ccfd1adeb1134df655a516c30a 100644 (file)
@@ -48,6 +48,7 @@ GITHUB_APP_ID=false
 GITHUB_APP_SECRET=false
 GOOGLE_APP_ID=false
 GOOGLE_APP_SECRET=false
+GOOGLE_SELECT_ACCOUNT=false
 OKTA_BASE_URL=false
 OKTA_APP_ID=false
 OKTA_APP_SECRET=false
index 87db1d5c6d4f1bfeadfb28c173da36e777b1b6a9..66f567c98389ab2ed5bdecd19faa20761c7fd76c 100644 (file)
@@ -40,7 +40,7 @@ class SocialAuthService
     public function startLogIn($socialDriver)
     {
         $driver = $this->validateDriver($socialDriver);
-        return $this->socialite->driver($driver)->redirect();
+        return $this->redirectToSocialProvider($driver)->redirect();
     }
 
     /**
@@ -52,7 +52,7 @@ class SocialAuthService
     public function startRegister($socialDriver)
     {
         $driver = $this->validateDriver($socialDriver);
-        return $this->socialite->driver($driver)->redirect();
+        return $this->redirectToSocialProvider($driver)->redirect();
     }
 
     /**
@@ -247,4 +247,18 @@ 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
+     */
+    public function redirectToSocialProvider($driver)
+    {
+        if ($driver == 'google' && config('services.google.select_account'))
+        {
+            return $this->socialite->driver($driver)->with(['prompt' => 'select_account']);
+        }
+
+        return $this->socialite->driver($driver);
+    }
 }
index 711040386a9ac17c954ad694ac3aece8b11a06de..857a7caa28ca197904fcf61fc3c7ff7ac9709e7b 100644 (file)
@@ -59,6 +59,7 @@ return [
         'name'          => 'Google',
         'auto_register' => env('GOOGLE_AUTO_REGISTER', false),
         'auto_confirm' => env('GOOGLE_AUTO_CONFIRM_EMAIL', false),
+        'select_account' => env('GOOGLE_SELECT_ACCOUNT', false),
     ],
 
     'slack'   => [