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 i
Given the following configuration of express-session
with connect-redis
as the session store (using Express 4):
redis = require('redis').createClient(6379, '127.0.0.1');
session = require('express-session');
RedisStore = require('connect-redis')(session);
app.use(session({
store: new RedisStore({
client: redis
}),
secret: 's3cret',
resave: true,
saveUninitialized: true
}));
You can just tell passport to serialize the entire user object, instead of just the user id.
passport.serializeUser(function(user, done){
done(null, user);
});
passport.deserializeUser(function(user, done){
done(null, user);
});
The entire user object will be saved with the session in Redis, and placed on the request as req.user
for every request.