From 29eae7ef166286e2cc78d40923df5209f6469a59 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Sun, 6 Aug 2017 09:38:39 +0200 Subject: [PATCH] baculum: Fix empty admin setting --- gui/baculum/protected/Web/Pages/WebHome.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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; } } -- 2.39.5