NOW MANAGED ON CODEBERG
Added google select_account test
Dan Brown178b5af83a3a
diff --git a/app/Auth/Access/SocialAuthService.php b/app/Auth/Access/SocialAuthService.phpindex 66f567c98..0d46b9f88 100644--- a/app/Auth/Access/SocialAuthService.php+++ b/app/Auth/Access/SocialAuthService.php@@ -40,7 +40,7 @@ class SocialAuthServicepublic function startLogIn($socialDriver){$driver = $this->validateDriver($socialDriver);- return $this->redirectToSocialProvider($driver)->redirect();+ return $this->getSocialDriver($driver)->redirect();}/**@@ -52,7 +52,7 @@ class SocialAuthServicepublic function startRegister($socialDriver){$driver = $this->validateDriver($socialDriver);- return $this->redirectToSocialProvider($driver)->redirect();+ return $this->getSocialDriver($driver)->redirect();}/**@@ -250,15 +250,17 @@ class SocialAuthService/*** Provide redirect options per service for the Laravel Socialite driver- * @param $driver+ * @param $driverName+ * @return \Laravel\Socialite\Contracts\Provider*/- public function redirectToSocialProvider($driver)+ public function getSocialDriver(string $driverName){- if ($driver == 'google' && config('services.google.select_account'))- {- return $this->socialite->driver($driver)->with(['prompt' => 'select_account']);+ $driver = $this->socialite->driver($driverName);++ if ($driverName === 'google' && config('services.google.select_account')) {+ $driver->with(['prompt' => 'select_account']);}- return $this->socialite->driver($driver);+ return $driver;}}diff --git a/phpunit.xml b/phpunit.xmlindex efed0070e..3d18d9bbf 100644--- a/phpunit.xml+++ b/phpunit.xml@@ -41,6 +41,7 @@<env name="GOOGLE_APP_SECRET" value="aaaaaaaaaaaaaa"/><env name="GOOGLE_AUTO_REGISTER" value=""/><env name="GOOGLE_AUTO_CONFIRM_EMAIL" value=""/>+ <env name="GOOGLE_SELECT_ACCOUNT" value=""/><env name="APP_URL" value="http://bookstack.dev"/><env name="DEBUGBAR_ENABLED" value="false"/></php>diff --git a/tests/Auth/SocialAuthTest.php b/tests/Auth/SocialAuthTest.phpindex 572c32f46..b8ca81174 100644--- a/tests/Auth/SocialAuthTest.php+++ b/tests/Auth/SocialAuthTest.php@@ -148,4 +148,12 @@ class SocialAuthTest extends TestCase$this->assertDatabaseHas('social_accounts', ['user_id' => $user->id]);}+ public function test_google_select_account_option_changes_redirect_url()+ {+ config()->set('services.google.select_account', 'true');++ $resp = $this->get('/login/service/google');+ $this->assertContains('prompt=select_account', $resp->headers->get('Location'));+ }+}