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 });