wip правки, рефактор, отдельный магазин.

This commit is contained in:
2023-07-07 18:36:23 +03:00
parent 48ca7b4109
commit d2cf95ef55
8 changed files with 847 additions and 363 deletions
+17
View File
@@ -63,5 +63,22 @@ class Password
'hash' => $hash ?? null,
];
}
public static function isGood(string $password, string $passwordHash, string $login): bool
{
if (password_verify($password, $passwordHash)) { // check password
return true;
} else {
if (
md5($password) === $passwordHash || // convert old md5() password
password_needs_rehash($passwordHash, PASSWORD_DEFAULT) //rehash if PASSWORD_DEFAULT changed
) {
$hash = password_hash($password, PASSWORD_DEFAULT);
Db::sql('update users set pass = ? where login = ?', [$hash, $login]);
return true;
}
return false;
}
}
}