Fix stupid code in ActionController::redirectToLogin()

refs #8626
This commit is contained in:
Eric Lippmann 2015-03-11 21:49:20 +01:00
parent 4ebfbf83ab
commit bc1336b6f9

View File

@ -293,35 +293,26 @@ class ActionController extends Zend_Controller_Action
} }
/** /**
* Redirect to the login path * Redirect to login
* *
* @param Url $afterLogin The action to call when the login was successful. Defaults to '/index/welcome' * XHR will always redirect to __SELF__. __SELF__ instructs JavaScript to redirect to the current window's URL
* if it's an auto-refresh request or to redirect to the URL which required login if it's not an auto-refreshing
* one.
* *
* @throws \Exception * @param Url|string $redirect URL to redirect to after successful login
*/ */
protected function redirectToLogin($afterLogin = null) protected function redirectToLogin($redirect = null)
{ {
$redir = null; $login = Url::fromPath('authentication/login');
if ($afterLogin !== null) {
if (! $afterLogin instanceof Url) {
$afterLogin = Url::fromPath($afterLogin);
}
if ($this->isXhr()) { if ($this->isXhr()) {
// __SELF__ instructs JavaScript to redirect to the current window's URL in case it's an auto-refreshing $login->setParam('redirect', '__SELF__');
// request or to redirect to the URL which required login in case it's not an auto-refreshing one } elseif ($redirect !== null) {
$redir = '__SELF__'; if (! $redirect instanceof Url) {
} else { $redirect = Url::fromPath($redirect);
// TODO: Ignore /?
$redir = $afterLogin->getRelativeUrl();
} }
$login->setParam('redirect', $redirect->getRelativeUrl());
} }
$this->rerenderLayout()->redirectNow($login);
$url = Url::fromPath('authentication/login');
if ($redir) {
$url->setParam('redirect', $redir);
}
$this->rerenderLayout()->redirectNow($url);
} }
protected function rerenderLayout() protected function rerenderLayout()