Skip to content

Commit f8a299c

Browse files
committed
Fixed login 'intended' redirect for custom urls.
Also changed social account detach wording.
1 parent 437dce7 commit f8a299c

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

app/Http/Controllers/Auth/AuthController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ protected function authenticated(Request $request, Authenticatable $user)
145145
auth()->login($user);
146146
}
147147

148-
return redirect()->intended($this->redirectPath());
148+
$path = session()->pull('url.intended', '/');
149+
$path = baseUrl($path, true);
150+
return redirect($path);
149151
}
150152

151153
/**

app/Services/SocialAuthService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function detachSocialAccount($socialDriver)
215215
{
216216
session();
217217
auth()->user()->socialAccounts()->where('driver', '=', $socialDriver)->delete();
218-
\Session::flash('success', $socialDriver . ' account successfully detached');
218+
session()->flash('success', title_case($socialDriver) . ' account successfully detached');
219219
return redirect(auth()->user()->getEditUrl());
220220
}
221221

app/helpers.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,21 @@ function setting($key, $default = false)
6464

6565
/**
6666
* Helper to create url's relative to the applications root path.
67-
* @param $path
67+
* @param string $path
68+
* @param bool $forceAppDomain
6869
* @return string
6970
*/
70-
function baseUrl($path)
71+
function baseUrl($path, $forceAppDomain = false)
7172
{
72-
if (strpos($path, 'http') === 0) return $path;
73+
$isFullUrl = strpos($path, 'http') === 0;
74+
if ($isFullUrl && !$forceAppDomain) return $path;
7375
$path = trim($path, '/');
76+
77+
if ($isFullUrl && $forceAppDomain) {
78+
$explodedPath = explode('/', $path);
79+
$path = implode('/', array_splice($explodedPath, 3));
80+
}
81+
7482
return rtrim(config('app.url'), '/') . '/' . $path;
7583
}
7684

0 commit comments

Comments
 (0)