Undefined function with bcrypt-nodejs Undefined function with bcrypt-nodejs mongoose mongoose

Undefined function with bcrypt-nodejs


Reproducable with this:

var bcrypt = require('bcrypt-nodejs')bcrypt.hash('foo', 10, null, function(err) {  if (err) throw err;});

The issue is that the salt needs to be a string (internally, bcrypt-nodejs is using salt.charAt(), and charAt() is undefined for numbers).

You probably want this:

 bcrypt.hash(self.passHash, bcrypt.genSaltSync(SALT_WORK_FACTOR), ...);

(or the async version, bcrypt.genSalt())