mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: password verify
This commit is contained in:
@@ -809,11 +809,14 @@ App::patch('/v1/users/:userId/password')
|
||||
$history = [];
|
||||
if($historyLimit > 0) {
|
||||
$history = $user->getAttribute('passwordHistory', []);
|
||||
|
||||
if(in_array($newPassword, $history)) {
|
||||
throw new Exception(Exception::USER_PASSWORD_RECENTLY_USED, 'The password was recently used', 409);
|
||||
|
||||
foreach($history as $hash) {
|
||||
if(Auth::passwordVerify($password, $hash, $user->getAttribute('hash'), $user->getAttribute('hashOptions')))
|
||||
{
|
||||
throw new Exception(Exception::USER_PASSWORD_RECENTLY_USED, 'The password was recently used', 409);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$history[] = $newPassword;
|
||||
while(count($history) > $historyLimit) {
|
||||
array_pop($history);
|
||||
|
||||
Reference in New Issue
Block a user