AuthenticationController: handle redirect parameter
This is a form field instead of a get parameter right now. fixes #6584
This commit is contained in:
parent
17b64f9dd5
commit
f67d273bbd
|
@ -35,12 +35,17 @@ class AuthenticationController extends ActionController
|
||||||
public function loginAction()
|
public function loginAction()
|
||||||
{
|
{
|
||||||
$auth = $this->Auth();
|
$auth = $this->Auth();
|
||||||
$this->view->form = new LoginForm();
|
$this->view->form = $form = new LoginForm();
|
||||||
$this->view->form->setRequest($this->_request);
|
$form->setRequest($this->_request);
|
||||||
$this->view->title = $this->translate('Icingaweb Login');
|
$this->view->title = $this->translate('Icingaweb Login');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$redirectUrl = Url::fromPath($this->params->get('redirect', 'dashboard'));
|
$redirectUrl = $this->view->form->getValue('redirect');
|
||||||
|
if ($redirectUrl) {
|
||||||
|
$redirectUrl = Url::fromPath($redirectUrl);
|
||||||
|
} else {
|
||||||
|
$redirectUrl = Url::fromPath('dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
if ($auth->isAuthenticated()) {
|
if ($auth->isAuthenticated()) {
|
||||||
$this->rerenderLayout()->redirectNow($redirectUrl);
|
$this->rerenderLayout()->redirectNow($redirectUrl);
|
||||||
|
@ -72,12 +77,20 @@ class AuthenticationController extends ActionController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($this->view->form->isSubmittedAndValid()) {
|
} elseif ($form->isSubmittedAndValid()) {
|
||||||
$user = new User($this->view->form->getValue('username'));
|
$user = new User($form->getValue('username'));
|
||||||
$password = $this->view->form->getValue('password');
|
$password = $form->getValue('password');
|
||||||
$backendsTried = 0;
|
$backendsTried = 0;
|
||||||
$backendsWithError = 0;
|
$backendsWithError = 0;
|
||||||
|
|
||||||
|
$redirectUrl = $form->getValue('redirect');
|
||||||
|
|
||||||
|
if ($redirectUrl) {
|
||||||
|
$redirectUrl = Url::fromPath($redirectUrl);
|
||||||
|
} else {
|
||||||
|
$redirectUrl = Url::fromPath('dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($chain as $backend) {
|
foreach ($chain as $backend) {
|
||||||
if ($backend instanceof AutoLoginBackend) {
|
if ($backend instanceof AutoLoginBackend) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -112,14 +125,14 @@ class AuthenticationController extends ActionController
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($backendsWithError) {
|
if ($backendsWithError) {
|
||||||
$this->view->form->addNote(
|
$form->addNote(
|
||||||
$this->translate(
|
$this->translate(
|
||||||
'Note that not all authentication backends are available for authentication because they'
|
'Note that not all authentication backends are available for authentication because they'
|
||||||
. ' have errors. Please check the system log or Icinga Web 2 log for more information'
|
. ' have errors. Please check the system log or Icinga Web 2 log for more information'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->view->form->getElement('password')->addError($this->translate('Incorrect username or password'));
|
$form->getElement('password')->addError($this->translate('Incorrect username or password'));
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->view->errorInfo = $e->getMessage();
|
$this->view->errorInfo = $e->getMessage();
|
||||||
|
|
Loading…
Reference in New Issue