mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-05-03 06:10:18 +02:00
Use a login-like layout for error messages displayed to non-authenticated users
refs #10009
This commit is contained in:
parent
426f64e32a
commit
8e29fe92a5
@ -29,13 +29,16 @@ class ErrorController extends ActionController
|
|||||||
*/
|
*/
|
||||||
public function errorAction()
|
public function errorAction()
|
||||||
{
|
{
|
||||||
$this->view->noAuthPageNotFound = false;
|
|
||||||
$error = $this->_getParam('error_handler');
|
$error = $this->_getParam('error_handler');
|
||||||
$exception = $error->exception;
|
$exception = $error->exception;
|
||||||
/** @var \Exception $exception */
|
/** @var \Exception $exception */
|
||||||
Logger::error($exception);
|
Logger::error($exception);
|
||||||
Logger::error('Stacktrace: %s', $exception->getTraceAsString());
|
Logger::error('Stacktrace: %s', $exception->getTraceAsString());
|
||||||
|
|
||||||
|
if (! ($isAuthenticated = $this->Auth()->isAuthenticated())) {
|
||||||
|
$this->innerLayout = 'error';
|
||||||
|
}
|
||||||
|
|
||||||
switch ($error->type) {
|
switch ($error->type) {
|
||||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
|
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
|
||||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
||||||
@ -46,16 +49,13 @@ class ErrorController extends ActionController
|
|||||||
$path = array_shift($path);
|
$path = array_shift($path);
|
||||||
$this->getResponse()->setHttpResponseCode(404);
|
$this->getResponse()->setHttpResponseCode(404);
|
||||||
$this->view->message = $this->translate('Page not found.');
|
$this->view->message = $this->translate('Page not found.');
|
||||||
if ($this->Auth()->isAuthenticated()) {
|
if ($isAuthenticated) {
|
||||||
if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) {
|
if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) {
|
||||||
$this->view->message .= ' ' . sprintf(
|
$this->view->message .= ' ' . sprintf(
|
||||||
$this->translate('Enabling the "%s" module might help!'),
|
$this->translate('Enabling the "%s" module might help!'),
|
||||||
$path
|
$path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$this->innerLayout = 'inline';
|
|
||||||
$this->view->noAuthPageNotFound = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -99,5 +99,6 @@ class ErrorController extends ActionController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->view->request = $error->request;
|
$this->view->request = $error->request;
|
||||||
|
$this->view->hideControls = ! $isAuthenticated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
application/layouts/scripts/error.phtml
Normal file
8
application/layouts/scripts/error.phtml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<div class="logo">
|
||||||
|
<div class="image">
|
||||||
|
<img aria-hidden="true" class="fade-in one" src="<?= $this->baseUrl('img/logo_icinga_big.png'); ?>" alt="<?= $this->translate('The Icinga logo'); ?>" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="below-logo">
|
||||||
|
<?= $this->render('inline.phtml') ?>
|
||||||
|
</div>
|
@ -1,25 +1,12 @@
|
|||||||
<?php if ($noAuthPageNotFound) { ?>
|
<?php if (! $hideControls) { ?>
|
||||||
<div id="login">
|
|
||||||
<div class="logo">
|
|
||||||
<div class="image">
|
|
||||||
<img aria-hidden="true" class="fade-in one" src="<?= $this->baseUrl('img/logo_icinga_big.png'); ?>" alt="<?= $this->translate('The Icinga logo'); ?>" >
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="below-logo" data-base-target="layout">
|
|
||||||
<div class="content">
|
|
||||||
<p><strong><?= nl2br($this->escape($message)) ?></strong></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php } else { ?>
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<?= $this->tabs->showOnlyCloseButton() ?>
|
<?= $this->tabs->showOnlyCloseButton() ?>
|
||||||
</div>
|
|
||||||
<div class="content">
|
|
||||||
<p><strong><?= nl2br($this->escape($message)) ?></strong></p>
|
|
||||||
<?php if (isset($stackTrace)) : ?>
|
|
||||||
<hr />
|
|
||||||
<pre><?= $this->escape($stackTrace) ?></pre>
|
|
||||||
<?php endif ?>
|
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<div class="content">
|
||||||
|
<p><strong><?= nl2br($this->escape($message)) ?></strong></p>
|
||||||
|
<?php if (isset($stackTrace)) : ?>
|
||||||
|
<hr />
|
||||||
|
<pre><?= $this->escape($stackTrace) ?></pre>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user