mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
ActionController: JS should redirect to __SELF__...
...once you lost your session. That's the only way to do this in a smooth way. When the server get's an unauthenticated request for a single container, redirecting to auth/login?redir=<that-container> was not what you expect. Together with JS handling __SELF__ in redirection URLs this will play fine. refs #6935
This commit is contained in:
parent
b9cc964e24
commit
9d4a4f49c9
@ -256,8 +256,20 @@ class ActionController extends Zend_Controller_Action
|
|||||||
*/
|
*/
|
||||||
protected function redirectToLogin($afterLogin = '/dashboard')
|
protected function redirectToLogin($afterLogin = '/dashboard')
|
||||||
{
|
{
|
||||||
|
if (! $afterLogin instanceof Url) {
|
||||||
|
$afterLogin = Url::fromPath($afterLogin);
|
||||||
|
}
|
||||||
|
if ($this->isXhr()) {
|
||||||
|
$redir = '__SELF__';
|
||||||
|
} else {
|
||||||
|
// TODO: Ignore /?
|
||||||
|
$redir = $afterLogin->getRelativeUrl();
|
||||||
|
}
|
||||||
$url = Url::fromPath('authentication/login');
|
$url = Url::fromPath('authentication/login');
|
||||||
$url->setParam('redirect', $afterLogin);
|
if ($redir) {
|
||||||
|
$url->setParam('redirect', $redir);
|
||||||
|
}
|
||||||
|
|
||||||
$this->rerenderLayout()->redirectNow($url);
|
$this->rerenderLayout()->redirectNow($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +285,27 @@ class ActionController extends Zend_Controller_Action
|
|||||||
return $this->getRequest()->isXmlHttpRequest();
|
return $this->getRequest()->isXmlHttpRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function redirectXhr($url)
|
||||||
|
{
|
||||||
|
if (! $url instanceof Url) {
|
||||||
|
$url = Url::fromPath($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->rerenderLayout) {
|
||||||
|
$this->getResponse()->setHeader('X-Icinga-Rerender-Layout', 'yes');
|
||||||
|
}
|
||||||
|
if ($this->reloadCss) {
|
||||||
|
$this->getResponse()->setHeader('X-Icinga-Reload-Css', 'now');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getResponse()
|
||||||
|
->setHeader('X-Icinga-Redirect', rawurlencode($url->getAbsoluteUrl()))
|
||||||
|
->sendHeaders();
|
||||||
|
|
||||||
|
// TODO: Session shutdown?
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirect to a specific url, updating the browsers URL field
|
* Redirect to a specific url, updating the browsers URL field
|
||||||
*
|
*
|
||||||
@ -280,26 +313,13 @@ class ActionController extends Zend_Controller_Action
|
|||||||
**/
|
**/
|
||||||
public function redirectNow($url)
|
public function redirectNow($url)
|
||||||
{
|
{
|
||||||
if (! $url instanceof Url) {
|
|
||||||
$url = Url::fromPath($url);
|
|
||||||
}
|
|
||||||
$url = preg_replace('~&~', '&', $url);
|
|
||||||
if ($this->isXhr()) {
|
if ($this->isXhr()) {
|
||||||
if ($this->rerenderLayout) {
|
$this->redirectXhr($url);
|
||||||
$this->getResponse()->setHeader('X-Icinga-Rerender-Layout', 'yes');
|
|
||||||
}
|
|
||||||
if ($this->reloadCss) {
|
|
||||||
$this->getResponse()->setHeader('X-Icinga-Reload-Css', 'now');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getResponse()
|
|
||||||
->setHeader('X-Icinga-Redirect', rawurlencode($url))
|
|
||||||
->sendHeaders();
|
|
||||||
|
|
||||||
// TODO: Session shutdown?
|
|
||||||
exit;
|
|
||||||
} else {
|
} else {
|
||||||
$this->_helper->Redirector->gotoUrlAndExit(Url::fromPath($url)->getRelativeUrl());
|
if (! $url instanceof Url) {
|
||||||
|
$url = Url::fromPath($url);
|
||||||
|
}
|
||||||
|
$this->_helper->Redirector->gotoUrlAndExit($url->getRelativeUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user