Skip to content

Commit

Permalink
Improvements from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
MyvTsv committed Sep 13, 2024
1 parent eb5880d commit 60d4f64
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions front/inventory.conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/Glpi/Agent/Communication/Headers/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

class Common
{

//Global headers
/**
* "Content-Type" HTTP header
Expand Down
13 changes: 5 additions & 8 deletions src/Glpi/Inventory/Conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 60d4f64

Please sign in to comment.