Use a login-like layout for error messages displayed to non-authenticated users

refs #10009
This commit is contained in:
Alexander A. Klimov 2015-09-22 18:21:25 +02:00
parent 426f64e32a
commit 8e29fe92a5
3 changed files with 23 additions and 27 deletions

View File

@ -29,13 +29,16 @@ class ErrorController extends ActionController
*/
public function errorAction()
{
$this->view->noAuthPageNotFound = false;
$error = $this->_getParam('error_handler');
$exception = $error->exception;
/** @var \Exception $exception */
Logger::error($exception);
Logger::error('Stacktrace: %s', $exception->getTraceAsString());
if (! ($isAuthenticated = $this->Auth()->isAuthenticated())) {
$this->innerLayout = 'error';
}
switch ($error->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
@ -46,16 +49,13 @@ class ErrorController extends ActionController
$path = array_shift($path);
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = $this->translate('Page not found.');
if ($this->Auth()->isAuthenticated()) {
if ($isAuthenticated) {
if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) {
$this->view->message .= ' ' . sprintf(
$this->translate('Enabling the "%s" module might help!'),
$path
);
}
} else {
$this->innerLayout = 'inline';
$this->view->noAuthPageNotFound = true;
}
break;
@ -99,5 +99,6 @@ class ErrorController extends ActionController
}
$this->view->request = $error->request;
$this->view->hideControls = ! $isAuthenticated;
}
}

View 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>

View File

@ -1,25 +1,12 @@
<?php if ($noAuthPageNotFound) { ?>
<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 { ?>
<?php if (! $hideControls) { ?>
<div class="controls">
<?= $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 ?>
<?= $this->tabs->showOnlyCloseButton() ?>
</div>
<?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>