title: 'req.flash' is not a function
body: <p>I'm workin with passport-local, but when I try it express send me the error: req.flash is not a function. I have been searching how to solve it but found nothing</p>
  
  <p>this is my configuration and code:</p>
  
  <p>App.js</p>
  
  <pre><code> `...imports like body parser, express, etc
    var passport = require('passport');
    var flash = require('connect-flash');
  
    ...app.js code
  
    app.use(session({
     key : config.session.key,
     secret : config.session.secret,
     resave : false,
     saveUninitialized : false,
     cookie: { maxAge: 60000 }
    }));
  
    app.use(flash());
  
    app.use(passport.initialize());
    app.use(passport.session());`
  </code></pre>
  
  <p>accountController.js</p>
  
  <pre><code>`var mongoose = require('mongoose');
   var flash = require('connect-flash');
   var User = require('../models/userSchema');
  
   var passport = require('passport');
   var LocalStrategy = require('passport-local').Strategy;
  
   module.exports = function(passport){
  
     passport.serializeUser(function(user, done) {
      done(null, user.id);
     });
  
     passport.deserializeUser(function(id, done) {
       User.findById(id, function(err, user) {
         done(err, user);
       });
     });
  
     passport.use(new LocalStrategy({
  
       passReqToCallback : true
  
      },function(req, username, password, done){
          User.findOne({ app_id : username }, function(err, user){
              if(err) { return done(err); }
              if(!user){
                  return done(null, false, { message: 'Id o contraseña incorrectos'});
              }
              if(!user.validPassword(password)){
                  return done(null, false, { message: 'Id o contraseña incorrectos'});
              }
              return done(null, user);
          });
       }
   ));
  };`
  </code></pre>
  
  <p>account.js (route)</p>
  
  <pre><code>`var express = require('express');
   var router = express.Router();
  
   var passport = require('passport');
   require('../controller/accountController')(passport);
  
   var controller = require('../controller/accountController');
  
  router.route('/(:err)?')
    /*.get(controller.accountPage)*/
      .post(passport.authenticate('local',{
  
          successRedirect: '/dashboard',
          failureRedirect: '/acount',
          failureFlash: true
  
       }));
  
  
  module.exports = router;
  </code></pre>