How to use the compareAsync function from bcrypt-nodejs
Find comprehensive JavaScript bcrypt-nodejs.compareAsync code examples handpicked from public code repositorys.
GitHub: codyseibert/tab-tracker
29 30 31 32 33 34 35 36 37 38
beforeSave: hashPassword } }) User.prototype.comparePassword = function (password) { return bcrypt.compareAsync(password, this.password) } User.associate = function (models) { }
197
506
37
GitHub: FlipSideHR/FlyptoX
56 57 58 59 60 61 62 63 64 65
User.verify = Promise.method(function(email, password){ if (!email || !password) return null; return new User({email: email.toLowerCase().trim()}) .fetch().then(function(user) { if(!user) return null; return bcrypt.compareAsync(password, user.get('password')).then(function(match){ if(!match) return null; return user; }); });
24
51
14
GitHub: Foodujour/Foodujour
68 69 70 71 72 73 74 75 76
}); }; // checks password async with stored password User.validPassword = function(password) { return bcrypt.compareAsync(password, this.passHash); }; module.exports = User;
10
0
8
17 18 19 20 21 22 23 24 25 26
bcrypt.compare(password, hash, function(err, result) { callback(err, result); }); } else { return bcrypt.compareAsync(password, hash); } } module.exports = {
4
4
2
GitHub: npoling/scratch-track
66 67 68 69 70 71 72 73 74
}); }; // checks password async with stored password User.validPassword = function(enteredPassword, passwordHash) { return bcrypt.compareAsync(enteredPassword, passwordHash); }; module.exports = User;
3
0
2
GitHub: nxhuy-github/film-tracker
27 28 29 30 31 32 33 34 35
beforeCreate: hashPassword } }); User.prototype.comparePassword = function (password) { return bcrypt.compareAsync(password, this.password); } module.exports = User;
0
1
1
GitHub: filmedin/filmedin
16 17 18 19 20 21 22 23 24 25
} if (rows.length === 0) { next(new Error('User does not exist')); } else { var user = rows[0]; bcrypt.compareAsync(password, user.password).then(result => { if (result) { var token = jwt.encode(user, 'secret'); res.json({token: token}); } else {
9
0
1
20 21 22 23 24 25 26 27 28 29
} }); }, comparePassword: function(attempted) { return bcrypt.compareAsync(attempted, this.get('password')); }, generatePassword: function(password) { return bcrypt.genSaltAsync(null)
4
0
5
GitHub: shelleywang/partyof4
14 15 16 17 18 19 20 21 22 23
console.log('Error: ', err); }); }; instanceMethods.comparePassword = function (user, potentialUser) { return bcrypt.compareAsync(potentialUser.password, user.password) .then(function (matched){ if(!matched) return bBird.resolve(false); else return bBird.resolve(user); });
3
0
2
GitHub: kincjf/ankroom
65 66 67 68 69 70 71 72 73 74
// data - [REQUIRED] - data to compare. // encrypted - [REQUIRED] - data to be compared to. // callback - [REQUIRED] - a callback to be fired once the data has been compared. // error - First parameter to the callback detailing any errors. // result - Second parameter to the callback providing whether the data and encrypted forms match [true | false]. bcrypt.compareAsync(candidatePassword, self.password).then(function(isMatch) { return cb(null, isMatch); }).catch(function(err) { if (err) { return cb(err);
1
4
7
GitHub: drabinowitz/CourseBuilder
5 6 7 8 9 10 11 12 13 14
var autoLogin = function(username,password,user){return user;}; var login = {}; login.local = function(username,password,user){ return bcrypt.compareAsync(password,user.get('password')); }; login.guest = autoLogin; login.github = autoLogin;
0
10
2
23 24 25 26 27 28 29 30 31
if (!user) { throw new Error('user not found'); } this.user = user.dataValues; return bcrypt.compareAsync(password, this.user.password); }) .then(function (isVerified) { if(isVerified) {
0
0
1
+ 4 other calls in file
43 44 45 46 47 48 49 50 51
} resolve(rows[0]) }) }) }, comparePassword: async (password, hashPassword) => bcrypt.compareAsync(password, hashPassword) } module.exports = User
0
0
1
bcrypt-nodejs.hashSync is the most popular function in bcrypt-nodejs (111 examples)