Hash editor passwords with Argon2id and upgrade old hashes.
Old hashes are replaced at login. Widen the column before deploying: ALTER TABLE editors MODIFY password VARCHAR(255) NOT NULL;
This commit is contained in:
+5
-2
@@ -26,12 +26,15 @@ if (isset($_SESSION['editor'])) {
|
||||
$stored_password = $row['password'];
|
||||
else $denied = TRUE;
|
||||
$getid->close();
|
||||
open_db('close');
|
||||
$compare_password = $_POST['password'] ?? '';
|
||||
$compare_password = is_string($_POST['password'] ?? NULL) ? $_POST['password'] : '';
|
||||
// password_verify() also accepts hashes made by the old crypt() call
|
||||
if (!password_verify($compare_password, $stored_password)) {
|
||||
$denied = TRUE;
|
||||
open_db('close');
|
||||
} else {
|
||||
// Move an old hash to the current algorithm while we have the password
|
||||
rehash_password($username, $compare_password, $stored_password);
|
||||
open_db('close');
|
||||
login_editor($username);
|
||||
// Keep user logged in with cookie, if they request it
|
||||
if (isset($_POST['remember'])) {
|
||||
|
||||
Reference in New Issue
Block a user