Do I implement Serialize and Deserialize?
RedisStore is setup as my session store with Express. Does this mean that I DO NOT implement Serialize and Deserialize? Will it happen automatically?
When I don't implement these methods I get the following Express error - 500 Error: failed to serialize user into session. When I do implement them I'm not sure what to put in the Deserialize.
The code below appears to work but the sessions are not persisting. I need to login everytime I visit the site.
Is there a good example anywhere of NodeJS + Passport + RedisStore?
var sessionStore = new RedisStore({
host: rtg.hostname,
port: rtg.port,
db: redisAuth[0],
pass: redisAuth[1]
});
passport.use(new ForceDotComStrategy({
clientID: clientId,
clientSecret: clientSecret,
callbackURL: myurl
},
function(token, tokenSecret, profile, done) {
console.log(profile);
return done(null, profile);
}
));
appSecure.configure('production', function(){
appSecure.use(allowCrossDomain);
appSecure.use(express.cookieParser(expressSecret));
appSecure.use(express.bodyParser());
appSecure.use(express.methodOverride());
appSecure.set('port', port);
appSecure.use(express.session({ secret: expressSecret, store: sessionStore, key:'expressSid', cookie: { maxAge : 604800, domain:'.domain.com'}}));
appSecure.use(passport.initialize());
appSecure.use(passport.session());
appSecure.use(appSecure.router);
appSecure.use(express.static(__dirname + '/public'));
appSecure.use(express.errorHandler());
});
passport.serializeUser(function( user, done ) {
done( null, user.id);
});
passport.deserializeUser(function( user, done ) {
done( null, user );
});