[Legacy] Fix change password

This commit is contained in:
Jack Anderson 2024-11-22 13:24:11 +00:00
parent a7e68066bc
commit acbfb0b025

View file

@ -105,12 +105,12 @@ if (!empty($_REQUEST['guid']) && !empty($_REQUEST['key'])) {
}
if (!$expired) {
$password = $_POST['new_password'] ?? '';
$usr = new user();
$errors = $usr->passwordValidationCheck($password);
// if the form is filled and we want to login
if (isset($_REQUEST['login']) && $_REQUEST['login'] == '1') {
if ($row['username'] == $_POST['user_name']) {
$password = $_POST['new_password'];
$usr = new user();
$errors = $usr->passwordValidationCheck($password);
if (!$errors) {
$usr_id = $usr->retrieve_user_id($_POST['user_name']);
$usr->retrieve($usr_id);
@ -136,8 +136,15 @@ if (!empty($_REQUEST['guid']) && !empty($_REQUEST['key'])) {
}
} else {
$redirect = false;
if ($_REQUEST['redirect'] === '1') {
$redirect = true;
if (!$errors && !empty($password)){
$usr_id = $usr->retrieve_user_id($_POST['user_name']);
$usr->retrieve($usr_id);
$usr->setNewPassword($password);
$query2 = "UPDATE users_password_link SET deleted='1' where id='" . $db->quote($_REQUEST['guid']) . "'";
DBManagerFactory::getInstance()->query($query2, true, "Error setting link for $usr->user_name: ");
if ($_REQUEST['redirect'] === '1') {
$redirect = true;
}
}
}
} else {