Created
June 9, 2016 12:44
-
-
Save nelreina/937a0dbb0f16b54d99f4d4418dc950cb to your computer and use it in GitHub Desktop.
es5
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
var passport = require('passport'); | |
var localStrategy = require('passport-local').Strategy; | |
passport.use(new localStrategy(basicAuth)); | |
passport.serializeUser(function(user, done) { | |
done(null, user.id); | |
}); | |
passport.deserializeUser(function(id, done) { | |
done(null, id); | |
}); | |
function basicAuth(username, password, done) { | |
if (username === 'foo' && password === 'bar'){ | |
return done(null, {profileName:'The Real Foo', id:1}); | |
} else { | |
return done(null, false); | |
} | |
return done(new Error("Error occured!")) | |
} | |
exports.authenticate = passport.authenticate('local', { session: false }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment