title: Bcrypt Not Saving Password?
body: <p>For some reason when I try to hash and save a password the new password is not saved to the database? I'm using MongoDB, NodeJS, and passport to let the users change their password. </p>
  
  <pre><code>UserSchema.pre('save', function(next) {
    var user = this;
    var SALT_FACTOR = 5;
  console.log('trying to save the password')
  
    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();
  });
  });
  });
  </code></pre>
  
  <p>Posting the save: </p>
  
  <pre><code>app.post('/reset/:token', function(req, res) {
    async.waterfall([
      function(done) {
        User.findOne({ resetPasswordToken: req.params.token, resetPasswordExpires: { $gt: Date.now() } }, function(err, user, next) {
          if (!user) {
            req.flash('error', 'Password reset token is invalid or has expired.');
            return res.redirect('back');
          }
  
  
          user.password = req.body.password;
          user.resetPasswordToken = undefined;
          user.resetPasswordExpires = undefined;
          console.log('password' + user.password  + 'and the user is' + user)
  
    user.save(function(err) {
    if (err) {
        console.log('here')
         return res.redirect('back');
    } else { 
        console.log('here2')
      req.logIn(user, function(err) {
        done(err, user);
      });
  
    }
          });
        });
      },
  </code></pre>