Fix being able to change your password to an empty password.

This commit is contained in:
Floorb 2022-04-20 18:07:32 -04:00
parent 4183286d5a
commit 628f3fa944

View file

@ -19,9 +19,8 @@ $user_password = $current_user->password;
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (!verifyCsrfToken()) { if (!verifyCsrfToken()) {
$error = 'Invalid CSRF token (do you have cookies enabled?)'; $error = 'Invalid CSRF token (do you have cookies enabled?)';
} else if (isset($_POST['cpassword'])) { } else if (isset($_POST['cpassword']) && !empty($_POST['old_password']) && !empty($_POST['password'])) {
$user_old_pass = $_POST['old_password']; if (pp_password_verify($_POST['old_password'], $user_password)) {
if (pp_password_verify($user_old_pass, $user_password)) {
$user_new_cpass = pp_password_hash($_POST['password']); $user_new_cpass = pp_password_hash($_POST['password']);
$current_user->password = $user_new_cpass; $current_user->password = $user_new_cpass;