diff --git a/front/inventory.conf.php b/front/inventory.conf.php index 995926747ef..2d644b8df40 100644 --- a/front/inventory.conf.php +++ b/front/inventory.conf.php @@ -45,8 +45,7 @@ $conf->displayImportFiles($_FILES); } elseif (isset($_POST['update'])) { unset($_POST['update']); - $conf_is_success = $conf->saveConf($_POST); - if ($conf_is_success) { + if ($conf->saveConf($_POST)) { Session::addMessageAfterRedirect( __s('Configuration has been updated'), false, diff --git a/src/Glpi/Agent/Communication/Headers/Common.php b/src/Glpi/Agent/Communication/Headers/Common.php index 4956a17bed4..aef2dc9cf0e 100644 --- a/src/Glpi/Agent/Communication/Headers/Common.php +++ b/src/Glpi/Agent/Communication/Headers/Common.php @@ -40,7 +40,6 @@ class Common { - //Global headers /** * "Content-Type" HTTP header diff --git a/src/Glpi/Inventory/Conf.php b/src/Glpi/Inventory/Conf.php index 618b95d3216..090d06ab3bc 100644 --- a/src/Glpi/Inventory/Conf.php +++ b/src/Glpi/Inventory/Conf.php @@ -1151,11 +1151,12 @@ public function saveConf(array $values) } if ( - ( - !$values['basic_auth_password'] || - !$values['basic_auth_login'] - ) && $values['auth_required'] === Conf::BASIC_AUTH + $values['auth_required'] === Conf::BASIC_AUTH && + !empty($values['basic_auth_password']) && + !empty($values['basic_auth_login']) ) { + $values['basic_auth_password'] = (new GLPIKey())->encrypt($values['basic_auth_password']); + } else { Session::addMessageAfterRedirect( __s("Basic Authentication is active. The login and/or password fields are missing."), false, @@ -1164,10 +1165,6 @@ public function saveConf(array $values) return false; } - if (!is_null($values['basic_auth_password'])) { - $values['basic_auth_password'] = (new GLPIKey())->encrypt($values['basic_auth_password']); - } - $to_process = []; foreach ($defaults as $prop => $default_value) { $to_process[$prop] = $values[$prop] ?? $default_value;