Skip to content

Instantly share code, notes, and snippets.

@nelreina
Created June 9, 2016 12:44
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 nelreina/937a0dbb0f16b54d99f4d4418dc950cb to your computer and use it in GitHub Desktop.
Save nelreina/937a0dbb0f16b54d99f4d4418dc950cb to your computer and use it in GitHub Desktop.
es5
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