Skip to content

Commit

Permalink
Rehash user passwords if suggested (PHP 8.4) - fixes #719
Browse files Browse the repository at this point in the history
  • Loading branch information
CatoTH committed Nov 2, 2024
1 parent dfe681e commit 97c58ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Content pages can now have attached files, just like the welcome text on the home page.
- Access to content pages can now be restricted to logged in users, admins or specific user groups.
- When merging amendments into a motion, the default setting now is to create a resolution, not a new motion.
- Security improvement: When logging in, and a new verion of PHP (like 8.4) suggests a stronger default password hashing, the stored hash is updated accordingly.
- A new translation is provided: Montenegrin (thanks to Danilo Boskovic)
- Some compatibility issues with PHP 8.4 were resolved.
- Bugfix: Tabular data was not encoded correctly in the PHP-based PDF export.
Expand Down
9 changes: 8 additions & 1 deletion models/db/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,14 @@ public function getSelectableUserOrganizations(): ?array

public function validatePassword(string $password): bool
{
return password_verify($password, $this->pwdEnc);
$correctPassword = password_verify($password, $this->pwdEnc);

if ($correctPassword && password_needs_rehash($this->pwdEnc, PASSWORD_DEFAULT)) {
$this->pwdEnc = password_hash($password, PASSWORD_DEFAULT);
$this->save();
}

return $correctPassword;
}

public function changePassword(string $newPassword): void
Expand Down

0 comments on commit 97c58ab

Please sign in to comment.