Last active
August 29, 2015 14:26
-
-
Save gartenfeld/c5459752352a424a6ff4 to your computer and use it in GitHub Desktop.
Passport authentication using basic credentials.
This file contains hidden or 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( // a new Local instance | |
function(username, password, done) { // passing in a function | |
User.findOne({ username: username }, function (err, user) { // Mongo interface | |
if (err) { return done(err); } // generic error | |
if (!user) { return done(null, false); } // user not found | |
if (!user.verifyPassword(password)) { return done(null, false); } // wrong password | |
return done(null, user); // authenticated, returns 'user' | |
}); | |
} | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment