From d9946b0207558895f8960b6c50af6cbee121d7b2 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 12 May 2023 19:31:26 -0600 Subject: [PATCH] Refine the authentication database class --- .../resources/classes/plugins/database.php | 44 +++++-------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/core/authentication/resources/classes/plugins/database.php b/core/authentication/resources/classes/plugins/database.php index 9781723d59..6de889eee4 100644 --- a/core/authentication/resources/classes/plugins/database.php +++ b/core/authentication/resources/classes/plugins/database.php @@ -26,8 +26,12 @@ class plugin_database { function database() { //pre-process some settings - $settings['theme']['favicon'] = !empty($settings['theme']['favicon']) ? $settings['theme']['favicon'] : PROJECT_PATH.'/themes/default/favicon.ico'; - $settings['login']['destination'] = !empty($settings['login']['destination']) ? $settings['login']['destination'] : ''; + $settings['theme']['favicon'] = !empty($_SESSION['theme']['favicon']['text']) ? $_SESSION['theme']['favicon']['text'] : PROJECT_PATH.'/themes/default/favicon.ico'; + $settings['login']['destination'] = !empty($_SESSION['login']['destination']['text']) ? $_SESSION['login']['destination']['text'] : ''; + $settings['users']['unique'] = !empty($_SESSION['users']['unique']['text']) ? $_SESSION['users']['unique']['text'] : ''; + $settings['theme']['logo'] = !empty($_SESSION['theme']['logo']['text']) ? $_SESSION['theme']['logo']['text'] : PROJECT_PATH.'/themes/default/images/logo_login.png'; + $settings['theme']['login_logo_width'] = !empty($_SESSION['theme']['login_logo_width']['text']) ? $_SESSION['theme']['login_logo_width']['text'] : 'auto; max-width: 300px'; + $settings['theme']['login_logo_height'] = !empty($_SESSION['theme']['login_logo_height']['text']) ? $_SESSION['theme']['login_logo_height']['text'] : 'auto; max-height: 300px'; //already authorized if (isset($_SESSION['authentication']['plugin']['database']) && $_SESSION['authentication']['plugin']['database']["authorized"]) { @@ -42,31 +46,6 @@ class plugin_database { //show the authentication code view if (empty($_REQUEST["username"]) && empty($_REQUEST["key"])) { - //login logo source - if (isset($_SESSION['theme']['logo_login']['text']) && $_SESSION['theme']['logo_login']['text'] != '') { - $login_logo_source = $_SESSION['theme']['logo_login']['text']; - } - else if (isset($_SESSION['theme']['logo']['text']) && $_SESSION['theme']['logo']['text'] != '') { - $login_logo_source = $_SESSION['theme']['logo']['text']; - } - else { - $login_logo_source = PROJECT_PATH.'/themes/default/images/logo_login.png'; - } - - //login logo dimensions - if (isset($_SESSION['theme']['login_logo_width']['text']) && $_SESSION['theme']['login_logo_width']['text'] != '') { - $login_logo_width = $_SESSION['theme']['login_logo_width']['text']; - } - else { - $login_logo_width = 'auto; max-width: 300px'; - } - if (isset($_SESSION['theme']['login_logo_height']['text']) && $_SESSION['theme']['login_logo_height']['text'] != '') { - $login_logo_height = $_SESSION['theme']['login_logo_height']['text']; - } - else { - $login_logo_height = 'auto; max-height: 300px'; - } - //get the domain $domain_array = explode(":", $_SERVER["HTTP_HOST"]); $domain_name = $domain_array[0]; @@ -99,10 +78,9 @@ class plugin_database { $view->assign("project_path", PROJECT_PATH); $view->assign("login_destination_url", $settings['login']['destination']); $view->assign("favicon", $settings['theme']['favicon']); - $view->assign("project_path", PROJECT_PATH); - $view->assign("login_logo_width", $login_logo_width); - $view->assign("login_logo_height", $login_logo_height); - $view->assign("login_logo_source", $login_logo_source); + $view->assign("login_logo_width", $settings['theme']['login_logo_width']); + $view->assign("login_logo_height", $settings['theme']['login_logo_height']); + $view->assign("login_logo_source", $settings['theme']['logo']); //add the token name and hash to the view //$view->assign("token_name", $token['name']); @@ -168,7 +146,7 @@ class plugin_database { $sql .= ")\n"; $parameters['username'] = $this->username; } - if ($_SESSION["users"]["unique"]["text"] === "global") { + if ($settings['users']['unique'] === "global") { //unique username - global (example: email address) } else { @@ -186,7 +164,7 @@ class plugin_database { $this->domain_name = $_SESSION['domain_name']; //get the domain uuid when users are unique globally - if ($_SESSION["users"]["unique"]["text"] === "global" && $row["domain_uuid"] !== $this->domain_uuid) { + if ($settings['users']['unique'] === "global" && $row["domain_uuid"] !== $this->domain_uuid) { //set the domain_uuid $this->domain_uuid = $row["domain_uuid"]; $this->domain_name = $row["domain_name"];