Fix report by Ahsan Aziz (can reset the password of another user that

did not request password reset).
This commit is contained in:
Laurent Destailleur 2021-07-05 17:29:10 +02:00
parent 8b07e99e05
commit 87f9530272

View File

@ -87,14 +87,14 @@ if (empty($reshook)) {
// Validate new password // Validate new password
if ($action == 'validatenewpassword' && $username && $passworduidhash) { if ($action == 'validatenewpassword' && $username && $passworduidhash) {
$edituser = new User($db); $edituser = new User($db);
$result = $edituser->fetch('', $_GET["username"]); $result = $edituser->fetch('', $username);
if ($result < 0) { if ($result < 0) {
$message = '<div class="error">'.dol_escape_htmltag($langs->trans("ErrorLoginDoesNotExists", $username)).'</div>'; $message = '<div class="error">'.dol_escape_htmltag($langs->trans("ErrorLoginDoesNotExists", $username)).'</div>';
} else { } else {
global $dolibarr_main_instance_unique_id; global $dolibarr_main_instance_unique_id;
//print $edituser->pass_temp.'-'.$edituser->id.'-'.$dolibarr_main_instance_unique_id.' '.$passworduidhash; //print $edituser->pass_temp.'-'.$edituser->id.'-'.$dolibarr_main_instance_unique_id.' '.$passworduidhash;
if (dol_verifyHash($edituser->pass_temp.'-'.$edituser->id.'-'.$dolibarr_main_instance_unique_id, $passworduidhash)) { if ($edituser->pass_temp && dol_verifyHash($edituser->pass_temp.'-'.$edituser->id.'-'.$dolibarr_main_instance_unique_id, $passworduidhash)) {
// Clear session // Clear session
unset($_SESSION['dol_login']); unset($_SESSION['dol_login']);
$_SESSION['dol_loginmesg'] = $langs->trans('NewPasswordValidated'); // Save message for the session page $_SESSION['dol_loginmesg'] = $langs->trans('NewPasswordValidated'); // Save message for the session page