Skip to content

Instantly share code, notes, and snippets.

@joepie91
Last active December 4, 2015 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joepie91/77b7ec9b8f21f342931b to your computer and use it in GitHub Desktop.
Save joepie91/77b7ec9b8f21f342931b to your computer and use it in GitHub Desktop.
passport.use(new LocalStrategy(
function(username, password, done) {
collections.UserCollection.forge()
.query(function (qb) {
qb.where('username', '=', username.toLowerCase());
})
.fetchOne()
.then(function (user) {
if (user == null) {
return done(null, false, { message: 'Incorrect credentials.' });
};
//var hashedPassword = bcrypt.hashSync(password, salt)
console.log(user.attributes.password);
return bcrypt.compareAsync(password, user.attributes.password);
})
.then(function(res) {
return done(null, user, { message: 'You are logged in.' });
})
.catch(function(err) {
return done(null, false, { message: 'Incorrect password.' });
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment