]> BookStack Code Mirror - bookstack/commitdiff
Fixed login 'intended' redirect for custom urls.
authorDan Brown <redacted>
Sun, 21 Aug 2016 13:49:40 +0000 (14:49 +0100)
committerDan Brown <redacted>
Sun, 21 Aug 2016 13:49:40 +0000 (14:49 +0100)
Also changed social account detach wording.

app/Http/Controllers/Auth/AuthController.php
app/Services/SocialAuthService.php
app/helpers.php

index 2cbc047ce75621a20029bf31fa7409601cfe1e87..f2d3b274108616163cf55413ff77be90bb0934b8 100644 (file)
@@ -145,7 +145,9 @@ class AuthController extends Controller
             auth()->login($user);
         }
 
-        return redirect()->intended($this->redirectPath());
+        $path = session()->pull('url.intended', '/');
+        $path = baseUrl($path, true);
+        return redirect($path);
     }
 
     /**
index 4b99df789c9f3c744a4d75c71b78971e34d663ac..7e1bd4246d34404e2b140171796544f3080dc314 100644 (file)
@@ -215,7 +215,7 @@ class SocialAuthService
     {
         session();
         auth()->user()->socialAccounts()->where('driver', '=', $socialDriver)->delete();
-        \Session::flash('success', $socialDriver . ' account successfully detached');
+        session()->flash('success', title_case($socialDriver) . ' account successfully detached');
         return redirect(auth()->user()->getEditUrl());
     }
 
index 541f23fbe046b4842e8c5df780e7ace8cbc0032d..e4f9b1b107c94cf1a9f47383b6f2634861eddb78 100644 (file)
@@ -64,13 +64,21 @@ function setting($key, $default = false)
 
 /**
  * Helper to create url's relative to the applications root path.
- * @param $path
+ * @param string $path
+ * @param bool $forceAppDomain
  * @return string
  */
-function baseUrl($path)
+function baseUrl($path, $forceAppDomain = false)
 {
-    if (strpos($path, 'http') === 0) return $path;
+    $isFullUrl = strpos($path, 'http') === 0;
+    if ($isFullUrl && !$forceAppDomain) return $path;
     $path = trim($path, '/');
+
+    if ($isFullUrl && $forceAppDomain) {
+        $explodedPath = explode('/', $path);
+        $path = implode('/', array_splice($explodedPath, 3));
+    }
+
     return rtrim(config('app.url'), '/') . '/' . $path;
 }