Skip to content

Instantly share code, notes, and snippets.

@ben-ng ben-ng/gist:5223411
Created Mar 22, 2013

Embed
What would you like to do?
User.verifyPassword = function (password, hash, callback) { //You need a callback because bcrypt.compare is async
bcrypt.compare(password, hash, function(err, isMatch) {
callback(err, isMatch);
});
}
//Usage:
exports.User.verifyPassword(password, user.password, function(err, isMatch) {
if(err) {
console.log("Error!");
throw err;
}
else {
if(isMatch) {
done(err,user);
}
else {
done(err,false);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.