mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 20:22:18 +00:00
Updated the login redirect logic to ignore mfa routes
This commit is contained in:
parent
bee5e2c7ca
commit
9eb65dcd78
@ -81,13 +81,7 @@ class LoginController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store the previous location for redirect after login
|
// Store the previous location for redirect after login
|
||||||
$previous = url()->previous('');
|
$this->updateIntendedFromPrevious();
|
||||||
if ($previous && $previous !== url('/login') && setting('app-public')) {
|
|
||||||
$isPreviousFromInstance = (strpos($previous, url('/')) === 0);
|
|
||||||
if ($isPreviousFromInstance) {
|
|
||||||
redirect()->setIntendedUrl($previous);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('auth.login', [
|
return view('auth.login', [
|
||||||
'socialDrivers' => $socialDrivers,
|
'socialDrivers' => $socialDrivers,
|
||||||
@ -228,4 +222,32 @@ class LoginController extends Controller
|
|||||||
$this->username() => [trans('auth.failed')],
|
$this->username() => [trans('auth.failed')],
|
||||||
])->redirectTo('/login');
|
])->redirectTo('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the intended URL location from their previous URL.
|
||||||
|
* Ignores if not from the current app instance or if from certain
|
||||||
|
* login or authentication routes.
|
||||||
|
*/
|
||||||
|
protected function updateIntendedFromPrevious(): void
|
||||||
|
{
|
||||||
|
// Store the previous location for redirect after login
|
||||||
|
$previous = url()->previous('');
|
||||||
|
$isPreviousFromInstance = (strpos($previous, url('/')) === 0);
|
||||||
|
if (!$previous || !setting('app-public') || !$isPreviousFromInstance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ignorePrefixList = [
|
||||||
|
'/login',
|
||||||
|
'/mfa',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($ignorePrefixList as $ignorePrefix) {
|
||||||
|
if (strpos($previous, url($ignorePrefix)) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
redirect()->setIntendedUrl($previous);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@ class MfaBackupCodesController extends Controller
|
|||||||
|
|
||||||
if (!auth()->check()) {
|
if (!auth()->check()) {
|
||||||
$this->showSuccessNotification(trans('auth.mfa_setup_login_notification'));
|
$this->showSuccessNotification(trans('auth.mfa_setup_login_notification'));
|
||||||
|
|
||||||
return redirect('/login');
|
return redirect('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user