X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/4e71a5a47b97bee59b8afff98b510c4d0d7ead15..refs/pull/806/head:/app/Services/SocialAuthService.php diff --git a/app/Services/SocialAuthService.php b/app/Services/SocialAuthService.php index 2c15e73ce..02361e59b 100644 --- a/app/Services/SocialAuthService.php +++ b/app/Services/SocialAuthService.php @@ -1,5 +1,7 @@ validateDriver($socialDriver); - // Get user details from social driver $socialUser = $this->socialite->driver($driver)->user(); $socialId = $socialUser->getId(); @@ -104,7 +105,8 @@ class SocialAuthService // When a user is not logged in and a matching SocialAccount exists, // Simply log the user into the application. if (!$isLoggedIn && $socialAccount !== null) { - return $this->logUserIn($socialAccount->user); + auth()->login($socialAccount->user); + return redirect()->intended('/'); } // When a user is logged in but the social account does not exist, @@ -134,14 +136,7 @@ class SocialAuthService $message .= trans('errors.social_account_register_instructions', ['socialAccount' => title_case($socialDriver)]); } - throw new SocialSignInException($message . '.', '/login'); - } - - - private function logUserIn($user) - { - auth()->login($user); - return redirect('/'); + throw new SocialSignInException($message, '/login'); } /** @@ -155,8 +150,12 @@ class SocialAuthService { $driver = trim(strtolower($socialDriver)); - if (!in_array($driver, $this->validSocialDrivers)) abort(404, trans('errors.social_driver_not_found')); - if (!$this->checkDriverConfigured($driver)) throw new SocialDriverNotConfigured(trans('errors.social_driver_not_configured', ['socialAccount' => title_case($socialDriver)])); + if (!in_array($driver, $this->validSocialDrivers)) { + abort(404, trans('errors.social_driver_not_found')); + } + if (!$this->checkDriverConfigured($driver)) { + throw new SocialDriverNotConfigured(trans('errors.social_driver_not_configured', ['socialAccount' => title_case($socialDriver)])); + } return $driver; } @@ -225,5 +224,4 @@ class SocialAuthService session()->flash('success', trans('settings.users_social_disconnected', ['socialAccount' => title_case($socialDriver)])); return redirect(user()->getEditUrl()); } - -} \ No newline at end of file +}