Using passport.js, I write the route so that I have access to the MongoDb userDoc document. But at the same time, so ... passport.serializeUser() will never be called and the req object will not be user .
auth.route('/auth/facebook/callback') .get(function(req, res, next) { passport.authenticate('facebook', function(err, userDoc, info) { if (err) { return next(err); }
But if I write it this way, req.user will be what it should be:
auth.route('/auth/facebook/callback') .get(passport.authenticate('facebook', { failureRedirect: '/login' }), function(req, res) { res.redirect('http://localhost:9000/users') });
How to do this, where passport.serializeUser is called, and user exists in req , and I also have access to the mongoDb object?
source share