Skip to content

Commit

Permalink
Merge pull request #4503 from corentin-soriano/fix_install
Browse files Browse the repository at this point in the history
Install improvements
  • Loading branch information
nilsteampassnet authored Nov 29, 2024
2 parents e49993f + f78b9a7 commit 6ad83d1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
12 changes: 1 addition & 11 deletions install/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ $(function() {
$("#step").val($(this).attr("target_id"));
document.upgrade.submit();
});

// no paste
$("#admin_pwd").bind("paste",function(e) {
alert("Paste option is disabled !!");
e.preventDefault();
});
});

function aesEncrypt(text)
Expand Down Expand Up @@ -137,7 +131,7 @@ function checkPage()
// STEP 6
jsonValues = {"url_path":sanitizeString($("#hid_url_path").val())};
dataToUse = JSON.stringify(jsonValues);
tasks = [ "file*settings.php","install*init", "file*security", "file*settings.php", "file*csrfp-token", "install*cleanup", "install*cronJob"];
tasks = ["file*settings.php","install*init", "file*security", "file*settings.php", "file*csrfp-token", "install*cleanup", "install*cronJob"];
multiple = true;
}

Expand Down Expand Up @@ -347,10 +341,6 @@ function GotoNextStep()
$("#step_result").html("");
$("#step_name").html($("#menu_step"+nextStep).html());
$("#step_content").html($("#text_step"+nextStep).html());
$('#admin_pwd').live("paste",function(e) {
alert("Paste option is disabled !!");
e.preventDefault();
});
$("#admin_pwd").live("keypress", function(e){
var key = e.charCode || e.keyCode || 0;
// allow backspace, tab, delete, arrows, letters, numbers and keypad numbers ONLY
Expand Down
13 changes: 7 additions & 6 deletions install/install.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ function encryptFollowingDefuse($message, $ascii_key)
KEY `ITEM` (`item_id`)
) CHARSET=utf8;"
);
} else if ($inputData['task'] === 'items_otp') {
} else if ($inputData['task'] === 'auth_failures') {
$mysqli_result = mysqli_query(
$dbTmp,
"CREATE TABLE IF NOT EXISTS `" . $var['tbl_prefix'] . "auth_failures` (
Expand Down Expand Up @@ -1569,11 +1569,6 @@ function encryptFollowingDefuse($message, $ascii_key)
);
fclose($file_handler);

// NOw remove old file
if (file_exists(__DIR__.'/../includes/config/'.SECUREFILE)) {
unlink(__DIR__.'/../includes/config/'.SECUREFILE);
}

// Create TP USER
require_once '../includes/config/include.php';
$tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `" . $var['tbl_prefix'] . "users` WHERE id = '" . TP_USER_ID . "'"));
Expand Down Expand Up @@ -1686,12 +1681,18 @@ function encryptFollowingDefuse($message, $ascii_key)

$crontabRepository->addJob($crontabJob);
$crontabRepository->persist();

// Now remove old file
if (file_exists(__DIR__.'/../includes/config/'.SECUREFILE)) {
unlink(__DIR__.'/../includes/config/'.SECUREFILE);
}
}
} catch (Exception $e) {
// do nothing
}
} else {
echo '[{"error" : "Cannot find PHP binary location. Please add a cronjob manually (see documentation).", "result":"", "index" : "' . $inputData['index'] . '", "multiple" : "' . $inputData['multiple'] . '"}]';
break;
}
echo '[{"error" : "", "index" : "' . $inputData['index'] . '", "multiple" : "' . $inputData['multiple'] . '"}]';
}
Expand Down
2 changes: 1 addition & 1 deletion install/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function getSettingValue($val)
<div class="form-group">
<label>Password</label>
<input type="text" class="form-control" name="db_pw" id="db_pw" class="ui-widget" value="'.DB_PASSWD_CLEAR.'">
<input type="password" class="form-control" name="db_pw" id="db_pw" class="ui-widget" value="'.DB_PASSWD_CLEAR.'">
</div>
<div class="form-group">
Expand Down
36 changes: 18 additions & 18 deletions sources/identify.php
Original file line number Diff line number Diff line change
Expand Up @@ -2110,24 +2110,6 @@ function identifyDoInitialChecks(
$oauth2Enabled = $SETTINGS['oauth2_enabled'] ?? false;
$lang = new Language($session->get('user-language') ?? 'english');

// Manage Maintenance mode
try {
$checks->isMaintenanceModeEnabled(
$SETTINGS['maintenance_mode'],
$userInfo['admin']
);
} catch (Exception $e) {
return [
'error' => true,
'skip_anti_bruteforce' => true,
'array' => [
'value' => '',
'error' => 'maintenance_mode_enabled',
'message' => '',
]
];
}

// Brute force management
try {
$checks->isTooManyPasswordAttempts($username, getClientIpServer());
Expand Down Expand Up @@ -2159,6 +2141,24 @@ function identifyDoInitialChecks(
];
}

// Manage Maintenance mode
try {
$checks->isMaintenanceModeEnabled(
$SETTINGS['maintenance_mode'],
$userInfo['admin']
);
} catch (Exception $e) {
return [
'error' => true,
'skip_anti_bruteforce' => true,
'array' => [
'value' => '',
'error' => 'maintenance_mode_enabled',
'message' => '',
]
];
}

// user should use MFA?
$userInfo['mfa_auth_requested_roles'] = mfa_auth_requested_roles(
(string) $userInfo['fonction_id'],
Expand Down

0 comments on commit 6ad83d1

Please sign in to comment.