title: Using PassportJS, how does one pass additional form fields to the local authentication strategy?
body: <p>I'm using passportJS and I'm wanting to supply more than just <code>req.body.username</code> and <code>req.body.password</code> to my authentication strategy (passport-local). </p>
  
  <p>I have 3 form fields: <code>username</code>, <code>password</code>, &amp; <code>foo</code></p>
  
  <p>How do I go about accessing <code>req.body.foo</code> from my local strategy which looks like:</p>
  
  <pre><code>passport.use(new LocalStrategy(
    {usernameField: 'email'},
      function(email, password, done) {
        User.findOne({ email: email }, function(err, user) {
          if (err) { return done(err); }
          if (!user) {
            return done(null, false, { message: 'Unknown user' });
          }
          if (password != 1212) {
            return done(null, false, { message: 'Invalid password' });
          }
          console.log('I just wanna see foo! ' + req.body.foo); // this fails!
          return done(null, user, aToken);
  
        });
      }
  ));
  </code></pre>
  
  <p>I'm calling this inside my route (not as route middleware) like so:</p>
  
  <pre><code>  app.post('/api/auth', function(req, res, next) {
      passport.authenticate('local', {session:false}, function(err, user, token_record) {
        if (err) { return next(err) }
        res.json({access_token:token_record.access_token});
     })(req, res, next);
  
    });
  </code></pre>