Let the error page look like the login page when a non-authenticated user requests a non-existent page

refs #10009
This commit is contained in:
Alexander A. Klimov 2015-09-22 18:21:25 +02:00
parent b69311165c
commit cd319f8c7d
2 changed files with 36 additions and 15 deletions

View File

@ -29,6 +29,7 @@ class ErrorController extends ActionController
*/
public function errorAction()
{
$this->view->noAuthPageNotFound = false;
$error = $this->_getParam('error_handler');
$exception = $error->exception;
/** @var \Exception $exception */
@ -45,11 +46,16 @@ class ErrorController extends ActionController
$path = array_shift($path);
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = $this->translate('Page not found.');
if ($this->Auth()->isAuthenticated() && $modules->hasInstalled($path) && ! $modules->hasEnabled($path)) {
$this->view->message .= ' ' . sprintf(
$this->translate('Enabling the "%s" module might help!'),
$path
);
if ($this->Auth()->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;

View File

@ -1,10 +1,25 @@
<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 ?>
</div>
<?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="form" data-base-target="layout">
<div class="content">
<p><strong><?= nl2br($this->escape($message)) ?></strong></p>
</div>
</div>
</div>
<?php } else { ?>
<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 ?>
</div>
<?php } ?>