X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/411c331a628a5db7e23686cf0d181c6f9e37fec6..refs/pull/139/head:/app/Services/SocialAuthService.php diff --git a/app/Services/SocialAuthService.php b/app/Services/SocialAuthService.php index b39a82d9f..ba3479349 100644 --- a/app/Services/SocialAuthService.php +++ b/app/Services/SocialAuthService.php @@ -1,14 +1,11 @@ -userRepo->getByEmail($socialUser->getEmail())) { + if ($this->userRepo->getByEmail($socialUser->getEmail())) { $email = $socialUser->getEmail(); - throw new UserRegistrationException('The email '. $email.' is already in use. If you already have an account you can connect your ' . $socialDriver .' account from your profile settings.', '/login'); + throw new UserRegistrationException('The email ' . $email . ' is already in use. If you already have an account you can connect your ' . $socialDriver . ' account from your profile settings.', '/login'); } return $socialUser; @@ -129,13 +126,13 @@ class SocialAuthService // When a user is logged in, A social account exists but the users do not match. // Change the user that the social account is assigned to. if ($isLoggedIn && $socialAccount !== null && $socialAccount->user->id != $currentUser->id) { - \Session::flash('success', 'This ' . title_case($socialDriver) . ' account is already used buy another user.'); + \Session::flash('success', 'This ' . title_case($socialDriver) . ' account is already used by another user.'); return redirect($currentUser->getEditUrl()); } // Otherwise let the user know this social account is not used by anyone. $message = 'This ' . $socialDriver . ' account is not linked to any users. Please attach it in your profile settings'; - if (\Setting::get('registration-enabled')) { + if (setting('registration-enabled')) { $message .= ' or, If you do not yet have an account, You can register an account using the ' . $socialDriver . ' option'; } throw new SocialSignInException($message . '.', '/login'); @@ -172,9 +169,10 @@ class SocialAuthService */ private function checkDriverConfigured($driver) { - $upperName = strtoupper($driver); - $config = [env($upperName . '_APP_ID', false), env($upperName . '_APP_SECRET', false), env('APP_URL', false)]; - return (!in_array(false, $config) && !in_array(null, $config)); + $lowerName = strtolower($driver); + $configPrefix = 'services.' . $lowerName . '.'; + $config = [config($configPrefix . 'client_id'), config($configPrefix . 'client_secret'), config('services.callback_url')]; + return !in_array(false, $config) && !in_array(null, $config); } /** @@ -193,7 +191,7 @@ class SocialAuthService } /** - * @param string $socialDriver + * @param string $socialDriver * @param \Laravel\Socialite\Contracts\User $socialUser * @return SocialAccount */