]> BookStack Code Mirror - bookstack/blobdiff - app/Services/SocialAuthService.php
Added ability to configure email sender name
[bookstack] / app / Services / SocialAuthService.php
index 6286a601445463f6a222237c747e7e8e4fbaa065..02361e59bbbb4852d7460d527d3bcac9f3b6765c 100644 (file)
@@ -1,5 +1,7 @@
 <?php namespace BookStack\Services;
 
+use BookStack\Http\Requests\Request;
+use GuzzleHttp\Exception\ClientException;
 use Laravel\Socialite\Contracts\Factory as Socialite;
 use BookStack\Exceptions\SocialDriverNotConfigured;
 use BookStack\Exceptions\SocialSignInException;
@@ -14,7 +16,7 @@ class SocialAuthService
     protected $socialite;
     protected $socialAccount;
 
-    protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter', 'azure', 'okta'];
+    protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter', 'azure', 'okta', 'gitlab', 'twitch'];
 
     /**
      * SocialAuthService constructor.
@@ -91,7 +93,6 @@ class SocialAuthService
     public function handleLoginCallback($socialDriver)
     {
         $driver = $this->validateDriver($socialDriver);
-
         // Get user details from social driver
         $socialUser = $this->socialite->driver($driver)->user();
         $socialId = $socialUser->getId();
@@ -135,7 +136,7 @@ class SocialAuthService
             $message .= trans('errors.social_account_register_instructions', ['socialAccount' => title_case($socialDriver)]);
         }
         
-        throw new SocialSignInException($message . '.', '/login');
+        throw new SocialSignInException($message, '/login');
     }
 
     /**
@@ -149,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;
     }
@@ -219,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
+}