1
0
Fork 0
mirror of synced 2024-06-28 19:20:25 +12:00

Update the Update Phone API to also set the password

This is to ensure the behavior matches the Update Email endpoint.
This commit is contained in:
Steven Nguyen 2023-05-31 13:52:05 -07:00
parent 5ef3162cee
commit 5afc49784e
No known key found for this signature in database

View file

@ -1706,6 +1706,14 @@ App::patch('/v1/account/phone')
->setAttribute('phoneVerification', false) // After this user needs to confirm phone number again
->setAttribute('search', implode(' ', [$user->getId(), $user->getAttribute('name', ''), $user->getAttribute('email', ''), $phone]));
if (empty($passwordUpdate)) {
$user
->setAttribute('password', Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS))
->setAttribute('hash', Auth::DEFAULT_ALGO)
->setAttribute('hashOptions', Auth::DEFAULT_ALGO_OPTIONS)
->setAttribute('passwordUpdate', DateTime::now());
}
try {
$user = $dbForProject->withRequestTimestamp($requestTimestamp, fn () => $dbForProject->updateDocument('users', $user->getId(), $user));
} catch (Duplicate $th) {