I first looked at regular sessions with a passport, mongodb and express , but this did not help and did not make sense.
I am trying to get persistent logins with my website . My serialization process is not working.
// Passport needs to be able to serialize and deserialize users to support persistent login sessions passport.serializeUser(function(user, done) { console.log('serializing user:',user.username); //return the unique id for the user return done(null, user._id); }); //Desieralize user will call with the unique id provided by serializeuser passport.deserializeUser(function(id, done) { User.findById(id, function(err, user) { console.log('deserializing user:',user.username); return done(err, user); }); });
The entire passport file can be found on github.
I think the problem is that I get deserialized immediately or at least what console.logs show.
Or it could be with my session:
app.use(session({ secret: 'keyboard cat', cookie : { maxAge: 3600000 // see below } }));
Here is my user schema:
var userSchema = new mongoose.Schema({ username : String, password : String,
Thanks for the help!
source share