diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 845a3a84ca..f08543aba6 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -112,11 +112,11 @@ App::post('/v1/account') 'email' => $email, 'emailVerification' => false, 'status' => true, - 'passwordHistory' => $passwordHistory > 0 ? [$password] : [], 'password' => $password, + 'passwordHistory' => $passwordHistory > 0 ? [$password] : [], + 'passwordUpdate' => DateTime::now(), 'hash' => Auth::DEFAULT_ALGO, 'hashOptions' => Auth::DEFAULT_ALGO_OPTIONS, - 'passwordUpdate' => DateTime::now(), 'registration' => DateTime::now(), 'reset' => false, 'name' => $name, @@ -1561,11 +1561,11 @@ App::patch('/v1/account/password') } $user = $dbForProject->updateDocument('users', $user->getId(), $user - ->setAttribute('passwordHistory', $history) ->setAttribute('password', $newPassword) + ->setAttribute('passwordHistory', $history) + ->setAttribute('passwordUpdate', DateTime::now())); ->setAttribute('hash', Auth::DEFAULT_ALGO) ->setAttribute('hashOptions', Auth::DEFAULT_ALGO_OPTIONS) - ->setAttribute('passwordUpdate', DateTime::now())); $events->setParam('userId', $user->getId()); @@ -2133,9 +2133,9 @@ App::put('/v1/account/recovery') $profile = $dbForProject->updateDocument('users', $profile->getId(), $profile ->setAttribute('password', Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS)) + ->setAttribute('passwordUpdate', DateTime::now()) ->setAttribute('hash', Auth::DEFAULT_ALGO) ->setAttribute('hashOptions', Auth::DEFAULT_ALGO_OPTIONS) - ->setAttribute('passwordUpdate', DateTime::now()) ->setAttribute('emailVerification', true)); $recoveryDocument = $dbForProject->getDocument('tokens', $recovery); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 25c37fe467..2768b28412 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -65,11 +65,11 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e 'phone' => $phone, 'phoneVerification' => false, 'status' => true, - 'passwordHistory' => is_null($password) && $passwordHistory === 0 ? [] : [$password], 'password' => $password, + 'passwordHistory' => is_null($password) && $passwordHistory === 0 ? [] : [$password], + 'passwordUpdate' => (!empty($password)) ? DateTime::now() : null, 'hash' => $hash === 'plaintext' ? Auth::DEFAULT_ALGO : $hash, 'hashOptions' => $hash === 'plaintext' ? Auth::DEFAULT_ALGO_OPTIONS : $hashOptionsObject + ['type' => $hash], - 'passwordUpdate' => (!empty($password)) ? DateTime::now() : null, 'registration' => DateTime::now(), 'reset' => false, 'name' => $name, @@ -822,11 +822,11 @@ App::patch('/v1/users/:userId/password') } $user - ->setAttribute('passwordHistory', $history) ->setAttribute('password', $newPassword) + ->setAttribute('passwordHistory', $history) + ->setAttribute('passwordUpdate', DateTime::now()) ->setAttribute('hash', Auth::DEFAULT_ALGO) - ->setAttribute('hashOptions', Auth::DEFAULT_ALGO_OPTIONS) - ->setAttribute('passwordUpdate', DateTime::now()); + ->setAttribute('hashOptions', Auth::DEFAULT_ALGO_OPTIONS); $user = $dbForProject->updateDocument('users', $user->getId(), $user);