I have made a set up to update a user\'s password using NodeJS/Passport. I followed this great guide: http://sahatyalkabov.com/how-to-implement-password-reset-in-nodejs/.
I already used this code in my current project, and its working fine, I saw a small error in your code in function UserSchema.pre('save', function(next). when you hash the password with bcrypt.hash then it took four arguments but there are only three argument in my code like
schema.pre('save', function(next) {
var user = this;
var SALT_FACTOR = 5;
if(!user.isModified('password')){
return next();
}
bcrypt.genSalt(SALT_FACTOR, function(err, salt) {
if(err){
return next(err);
}
bcrypt.hash(user.password, salt, function(err, hash) {
if(err){
return next(err);
}
user.password = hash;
next();
});
});
});
Third argument must be callback function see document for bcrypt