Update awards endpoint data and fix reset pass bug
This commit is contained in:
@@ -279,9 +279,15 @@ module.exports.update_user_password = [
|
||||
const salt = await bcrypt.genSalt(10)
|
||||
const hash = await bcrypt.hash(newPassword, salt)
|
||||
const user = await User.findById(user_id)
|
||||
if (!user) throw new Error(_faSr.not_found.user_id)
|
||||
if (!user) {
|
||||
res.status(404)
|
||||
throw new Error(_faSr.not_found.user_id)
|
||||
}
|
||||
const passwordMatch = await bcrypt.compare(password, user.password)
|
||||
if (!passwordMatch) throw new Error('err')
|
||||
if (!passwordMatch) {
|
||||
res.status(401)
|
||||
throw new Error('err')
|
||||
}
|
||||
user.password = hash
|
||||
await user.save()
|
||||
return res.json({ message: _faSr.response.success_save })
|
||||
|
||||
Reference in New Issue
Block a user