From: Marcin Haba Date: Sun, 6 Aug 2017 07:38:39 +0000 (+0200) Subject: baculum: Fix empty admin setting X-Git-Tag: Release-9.0.3~4 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=29eae7ef166286e2cc78d40923df5209f6469a59;p=bacula%2Fbacula baculum: Fix empty admin setting --- diff --git a/gui/baculum/protected/Web/Pages/WebHome.php b/gui/baculum/protected/Web/Pages/WebHome.php index 2842bc3f9c..b011050955 100644 --- a/gui/baculum/protected/Web/Pages/WebHome.php +++ b/gui/baculum/protected/Web/Pages/WebHome.php @@ -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; } }