]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Fix empty admin setting
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 6 Aug 2017 07:38:39 +0000 (09:38 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sun, 6 Aug 2017 08:40:33 +0000 (10:40 +0200)
gui/baculum/protected/Web/Pages/WebHome.php

index 2842bc3f9cdaac7d7f9c5cf86275e0cbf9cfd03b..b011050955247dfa2308f3a7f5f5358a9ed02328 100644 (file)
@@ -95,13 +95,17 @@ class WebHome extends BaculumWebPage
        }
 
        private function setSessionUserVars($cfg) {
-               // Set administrator role
-               $_SESSION['admin'] = ($_SERVER['PHP_AUTH_USER'] === $cfg['baculum']['login']);
-               // Set api host for normal user
-               if (!$_SESSION['admin'] && array_key_exists('users', $cfg) && array_key_exists($_SERVER['PHP_AUTH_USER'], $cfg['users'])) {
-                       $_SESSION['api_host'] = $cfg['users'][$_SERVER['PHP_AUTH_USER']];
-               } elseif (isset($_SESSION['api_host'])) {
-                       unset($_SESSION['api_hosts']);
+               if (count($cfg) > 0) {
+                       // Set administrator role
+                       $_SESSION['admin'] = ($_SERVER['PHP_AUTH_USER'] === $cfg['baculum']['login']);
+                       // Set api host for normal user
+                       if (!$_SESSION['admin'] && array_key_exists('users', $cfg) && array_key_exists($_SERVER['PHP_AUTH_USER'], $cfg['users'])) {
+                               $_SESSION['api_host'] = $cfg['users'][$_SERVER['PHP_AUTH_USER']];
+                       } elseif (isset($_SESSION['api_host'])) {
+                               unset($_SESSION['api_hosts']);
+                       }
+               } else {
+                       $_SESSION['admin'] = false;
                }
        }