Mongoose | Object changes in pre-save hook are not saved to db
The problem is that you're always calling next()
after the if
block, even when the password needs async encrypting.
Change your code to only do that for existing user
docs:
if(user.isNew){ bcrypt.genSalt(10, (err, salt) => { bcrypt.hash(user.password, salt, (err, hash) => { user.password = hash; console.log(user); next(); }) })}else { next();}