Skip to content

Commit

Permalink
webui: Fix login issue
Browse files Browse the repository at this point in the history
This commit fixes a login issue which occurred when the update
information could not be retrieved.

- Restructured AuthController for readability and optimization
- Use the ZF2 Session Container instead of $_SESSION
- Introduce AuthController method checkAPIStatusDIRD
- Introduce AuthController method checkACLStatusDIRD
- Introduce AuthController method checkUpdateStatusDIRD

The commit also fixes a minor issue with the UpdateAlert ViewHelper.

Fixes #1039: Can not login in webui

(cherry picked from commit 0691180)
  • Loading branch information
fbergkemper committed Sep 24, 2020
1 parent e90c2da commit f366ee9
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 126 deletions.
Expand Up @@ -5,7 +5,7 @@
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (c) 2013-2019 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @copyright Copyright (c) 2013-2020 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -26,42 +26,43 @@
namespace Application\Controller\Plugin;

use Zend\Mvc\Controller\Plugin\AbstractPlugin;
use Zend\Session\Container;

class SessionTimeoutPlugin extends AbstractPlugin
{
protected $session = null;

public function timeout()
{
$configuration = $this->getController()->getServiceLocator()->get('config');
$timeout = $configuration['configuration']['session']['timeout'];

if($timeout === 0) {
return true;
}
else {
if($_SESSION['bareos']['idletime'] + $timeout > time()) {
$_SESSION['bareos']['idletime'] = time();
return true;
}
else {
session_destroy();
return false;
} else {
if(($this->session->offsetGet('idletime') + $timeout) > time()) {
$this->session->offsetSet('idletime', time());
return false;
} else {
$this->session->getManager()->destroy();
return true;
}
}
}

public function isValid()
{
if($_SESSION['bareos']['authenticated']) {
$this->session = new Container('bareos');

if($this->session->offsetGet('authenticated')) {
if($this->timeout()) {
return true;
}
else {
return false;
} else {
return true;
}
}
else {
} else {
return false;
}
}

}
Expand Up @@ -32,16 +32,15 @@ class UpdateAlert extends AbstractHelper
protected $value;
protected $result;

public function __invoke($a=null,$b=null)
public function __invoke($product_updates_status=null, $dird_update_available=null)
{
if($a) {
if($b) {
$this->result = '<a data-toggle="tooltip" data-placement="bottom" href="http://download.bareos.com/" target="_blank"title="Updates available"><span class="glyphicon glyphicon-exclamation-sign text-danger" aria-hidden="true"></span></a>';
if($product_updates_status === false) {
$this->result = '<a data-toggle="tooltip" data-placement="bottom" href="http://download.bareos.com/" target="_blank"title="Update informaton could not be retrieved"><span class="glyphicon glyphicon-exclamation-sign text-danger" aria-hidden="true"></span></a>';
return $this->result;
}
}
else {
$this->result = '<a data-toggle="tooltip" data-placement="bottom" href="http://download.bareos.com/" target="_blank"title="Update informaton could not be retrieved"><span class="glyphicon glyphicon-exclamation-sign text-danger" aria-hidden="true"></span></a>';

if($dird_update_available === true) {
$this->result = '<a data-toggle="tooltip" data-placement="bottom" href="http://download.bareos.com/" target="_blank"title="Updates available"><span class="glyphicon glyphicon-exclamation-sign text-danger" aria-hidden="true"></span></a>';
return $this->result;
}
}
Expand Down

0 comments on commit f366ee9

Please sign in to comment.