Passport.js – Error: failed to serialize user into session
It looks like you didn’t implement passport.serializeUser and passport.deserializeUser. Try adding this:
It looks like you didn’t implement passport.serializeUser and passport.deserializeUser. Try adding this:
Follow the example to avoid the out-of-order middleware hell that express makes it so easy to enter. Straight from the docs. Note how yours does not match this exactly. Docs cookieParser session passport.initialize passport.session app.router You passport.initialize passport.session cookieParser session app.router
For any request you can check if a user is authenticated or not using this method.
The request object isn’t passed to the strategy callback by default, you need to set the passReqToCallback option for this: This is documented here.