Making login redirect you to where you were trying to go after logging in.
This commit is contained in:
parent
3a0e62657b
commit
a180d8ac08
|
@ -51,6 +51,7 @@ class Application extends b8\Application
|
|||
$response->setResponseCode(401);
|
||||
$response->setContent('');
|
||||
} else {
|
||||
$_SESSION['login_redirect'] = substr($request->getPath(), 1);
|
||||
$response = new RedirectResponse($response);
|
||||
$response->setHeader('Location', PHPCI_URL.'session/login');
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class SessionController extends \PHPCI\Controller
|
|||
|
||||
if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
|
||||
$_SESSION['user_id'] = $user->getId();
|
||||
header('Location: ' . PHPCI_URL);
|
||||
header('Location: ' . $this->getLoginRedirect());
|
||||
die;
|
||||
} else {
|
||||
$isLoginFailure = true;
|
||||
|
@ -159,4 +159,16 @@ MSG;
|
|||
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
protected function getLoginRedirect()
|
||||
{
|
||||
$rtn = PHPCI_URL;
|
||||
|
||||
if (!empty($_SESSION['login_redirect'])) {
|
||||
$rtn .= $_SESSION['login_redirect'];
|
||||
$_SESSION['login_redirect'] = null;
|
||||
}
|
||||
|
||||
return $rtn;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue