diff --git a/app/services/user.js b/app/services/user.js index 75a9eea..3b61e0c 100644 --- a/app/services/user.js +++ b/app/services/user.js @@ -667,6 +667,25 @@ class UserService extends SiteService { ); } + async updatePassword (user, password) { + const { crypto: cryptoService } = this.dtp.services; + + const passwordSalt = uuidv4(); + const passwordHash = cryptoService.maskPassword(passwordSalt, password); + + this.log.info('updating user password', { userId: user._id }); + + await User.updateOne( + { _id: user._id }, + { + $set: { + passwordSalt: passwordSalt, + password: passwordHash, + } + } + ); + } + /** * Updates the `lastAnnouncement` field of a User to the `created` date of the * specified announcement (for tracking last-seen announcements).