Passport and connect-flash: req.flash is not a function

The request object isn’t passed to the strategy callback by default, you need to set the passReqToCallback option for this:

passport.use(new LocalStrategy({
  passReqToCallback : true
}, function(req, username, password, done) { ... }));

This is documented here.

Leave a Comment