]> BookStack Code Mirror - bookstack/blobdiff - app/Services/SocialAuthService.php
Finished migration of last angular code
[bookstack] / app / Services / SocialAuthService.php
index 710f956963f56885d35d21a56536d618e78c9327..ddcdc9ba63a042363fb4626a38d17f88e7adc45e 100644 (file)
@@ -104,7 +104,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,
@@ -137,13 +138,6 @@ class SocialAuthService
         throw new SocialSignInException($message . '.', '/login');
     }
 
-
-    private function logUserIn($user)
-    {
-        auth()->login($user);
-        return redirect('/');
-    }
-
     /**
      * Ensure the social driver is correct and supported.
      *
@@ -181,14 +175,24 @@ class SocialAuthService
     public function getActiveDrivers()
     {
         $activeDrivers = [];
-        foreach ($this->validSocialDrivers as $driverName) {
-            if ($this->checkDriverConfigured($driverName)) {
-                $activeDrivers[$driverName] = true;
+        foreach ($this->validSocialDrivers as $driverKey) {
+            if ($this->checkDriverConfigured($driverKey)) {
+                $activeDrivers[$driverKey] = $this->getDriverName($driverKey);
             }
         }
         return $activeDrivers;
     }
 
+    /**
+     * Get the presentational name for a driver.
+     * @param $driver
+     * @return mixed
+     */
+    public function getDriverName($driver)
+    {
+        return config('services.' . strtolower($driver) . '.name');
+    }
+
     /**
      * @param string                            $socialDriver
      * @param \Laravel\Socialite\Contracts\User $socialUser