Skip to content

Instantly share code, notes, and snippets.

@jmas
Created April 28, 2015 15:16
Show Gist options
  • Save jmas/29490a7a38ac6bda1bed to your computer and use it in GitHub Desktop.
Save jmas/29490a7a38ac6bda1bed to your computer and use it in GitHub Desktop.
// passport
passport.use(new LocalStrategy(
function(username, password, next) {
userService.findByUsername(username)
.then(function(user) {
if (! user) {
return userService.save({
username: username,
password: password
});
}
if (! user.validPassword(password)) {
return next(new Error('Password not valid.'));
}
return user;
})
.then(function(user) {
next(null, user);
})
.catch(next);
// userService.findByUsernamePassword(username, password)
// .then(function(user) {
// next(null, user);
// })
// .catch(next);
}
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment