Skip to content

Commit

Permalink
Let the error page look like the login page when a non-authenticated …
Browse files Browse the repository at this point in the history
…user requests a non-existent page

refs #10009
  • Loading branch information
Al2Klimov committed Sep 22, 2015
1 parent b693111 commit cd319f8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
16 changes: 11 additions & 5 deletions application/controllers/ErrorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -45,11 +46,16 @@ public function errorAction()
$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;
Expand Down
35 changes: 25 additions & 10 deletions application/views/scripts/error/error.phtml
Original file line number Diff line number Diff line change
@@ -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 } ?>

0 comments on commit cd319f8

Please sign in to comment.