namespace BookStack\Http\Controllers\Auth;
+use BookStack\Actions\ActivityType;
use BookStack\Auth\Access\RegistrationService;
use BookStack\Auth\Access\SocialAuthService;
use BookStack\Exceptions\SocialDriverNotConfigured;
use BookStack\Exceptions\SocialSignInAccountNotUsed;
use BookStack\Exceptions\SocialSignInException;
use BookStack\Exceptions\UserRegistrationException;
+use BookStack\Facades\Theme;
use BookStack\Http\Controllers\Controller;
-use Illuminate\Http\RedirectResponse;
+use BookStack\Theming\ThemeEvents;
use Illuminate\Http\Request;
-use Illuminate\Routing\Redirector;
use Illuminate\Support\Str;
use Laravel\Socialite\Contracts\User as SocialUser;
$this->registrationService = $registrationService;
}
-
/**
* Redirect to the relevant social site.
- * @throws \BookStack\Exceptions\SocialDriverNotConfigured
+ * @throws SocialDriverNotConfigured
*/
- public function getSocialLogin(string $socialDriver)
+ public function login(string $socialDriver)
{
session()->put('social-callback', 'login');
return $this->socialAuthService->startLogIn($socialDriver);
* @throws SocialDriverNotConfigured
* @throws UserRegistrationException
*/
- public function socialRegister(string $socialDriver)
+ public function register(string $socialDriver)
{
$this->registrationService->ensureRegistrationAllowed();
session()->put('social-callback', 'register');
* @throws SocialDriverNotConfigured
* @throws UserRegistrationException
*/
- public function socialCallback(Request $request, string $socialDriver)
+ public function callback(Request $request, string $socialDriver)
{
if (!session()->has('social-callback')) {
throw new SocialSignInException(trans('errors.social_no_action_defined'), '/login');
/**
* Detach a social account from a user.
*/
- public function detachSocialAccount(string $socialDriver)
+ public function detach(string $socialDriver)
{
$this->socialAuthService->detachSocialAccount($socialDriver);
session()->flash('success', trans('settings.users_social_disconnected', ['socialAccount' => Str::title($socialDriver)]));
protected function socialRegisterCallback(string $socialDriver, SocialUser $socialUser)
{
$socialUser = $this->socialAuthService->handleRegistrationCallback($socialDriver, $socialUser);
- $socialAccount = $this->socialAuthService->fillSocialAccount($socialDriver, $socialUser);
+ $socialAccount = $this->socialAuthService->newSocialAccount($socialDriver, $socialUser);
$emailVerified = $this->socialAuthService->driverAutoConfirmEmailEnabled($socialDriver);
// Create an array of the user data to create a new user instance
$user = $this->registrationService->registerUser($userData, $socialAccount, $emailVerified);
auth()->login($user);
+ Theme::dispatch(ThemeEvents::AUTH_LOGIN, $socialDriver, $user);
+ $this->logActivity(ActivityType::AUTH_LOGIN, $user);
$this->showSuccessNotification(trans('auth.register_success'));
return redirect('/');