Last active
December 4, 2015 03:02
-
-
Save joepie91/77b7ec9b8f21f342931b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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