<?php namespace BookStack\Auth\Access;
-use BookStack\Exceptions\SocialSignInAccountNotUsed;
-use Laravel\Socialite\Contracts\Factory as Socialite;
+use BookStack\Auth\SocialAccount;
+use BookStack\Auth\UserRepo;
use BookStack\Exceptions\SocialDriverNotConfigured;
+use BookStack\Exceptions\SocialSignInAccountNotUsed;
use BookStack\Exceptions\UserRegistrationException;
-use BookStack\Auth\UserRepo;
-use BookStack\Auth\SocialAccount;
+use Laravel\Socialite\Contracts\Factory as Socialite;
use Laravel\Socialite\Contracts\User as SocialUser;
class SocialAuthService
public function startLogIn($socialDriver)
{
$driver = $this->validateDriver($socialDriver);
- return $this->socialite->driver($driver)->redirect();
+ return $this->getSocialDriver($driver)->redirect();
}
/**
public function startRegister($socialDriver)
{
$driver = $this->validateDriver($socialDriver);
- return $this->socialite->driver($driver)->redirect();
+ return $this->getSocialDriver($driver)->redirect();
}
/**
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;
+ }
}