title: Property of Mongoose Schema is undefined
body: <p>I get this error when I try to create a new User account with my app.</p>
  
  <p><code>TypeError: Cannot read property 'firstName' of undefined</code></p>
  
  <p>This is my models.js file</p>
  
  <pre><code>mongoose.model('User', new mongoose.Schema({
          firstName: String,
          lastName: String,
          email: String,
          passwordHash: String,
          subscriptionActive: {type: Boolean, default: false},
          customerId: String,
          subscriptionId: String,
  })); 
  </code></pre>
  
  <p>This is my front-end code.</p>
  
  <pre><code>&lt;form class="user" action="/signup" method="post"&gt;
                  &lt;div class="form-group row"&gt;
                    &lt;div class="col-sm-6 mb-3 mb-sm-0"&gt;
                      &lt;input type="text" class="form-control form-control-user" required name="firstName" placeholder="First Name"&gt;
                    &lt;/div&gt;
                    &lt;div class="col-sm-6"&gt;
                      &lt;input type="text" class="form-control form-control-user" required name="lastName" placeholder="Last Name"&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                    &lt;input class="form-control form-control-user" required type="email" name="email" placeholder="Email"/&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group row"&gt;
                    &lt;div class="col-sm-6 mb-3 mb-sm-0"&gt;
                      &lt;input class="form-control form-control-user" required type="Password" name="password" placeholder="password"/&gt;
                    &lt;/div&gt;
  </code></pre>
  
  <p>And these are relevant pieces from my app code:</p>
  
  <pre class="lang-js prettyprint-override"><code>var createError = require('http-errors');
  var express = require('express');
  var path = require('path');
  var cookieParser = require('cookie-parser');
  var logger = require('morgan');
  var mongoose = require('mongoose');
  require('./models.js');
  var bcrypt = require('bcryptjs');
  var expressSession = require('express-session');
  var passport = require('passport');
  var LocalStrategy = require('passport-local').Strategy;
  var dotenv = require('dotenv');
  dotenv.config();
  const bodyParser = require('body-parser');
  
  var User = mongoose.model('User');
  mongoose.connect('{confidential}', { useNewUrlParser: true, useUnifiedTopology: true  });
  
  // Middleware
  app.use(logger('dev'));
  app.use(express.json());
  app.use(express.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  app.use(expressSession({
    secret: process.env.EXPRESS_SESSION_SECRET,
  }));
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  
  passport.use("signup-local", new LocalStrategy({
    usernameField: "email",
    passwordField: "password"
  }, function(req, email, password, next) {
    console.log('req :',req, 'req.body :', req.body);
    User.findOne({
      email: email
    }, function(err, user)  {
      if (err) return next(err);
      if (user) return next({message: "User already exists"});
  
      let newUser = new User({
        firstName: req.body.firstName,
        lastName: req.body.lastName, 
        email: email,
        passwordHash: bcrypt.hashSync(password, 10), // Could potentially be hashed asynchronously
      });
      // If newUser is passed successfully redirect to the main page
      newUser.save(function(err) {
        next(err, newUser);
      });
    });
  
  }));
  
  app.post('/signup', passport.authenticate('signup-local', { failureRedirect: '/' }),
      function(req, res) {
        res.redirect('/main');
      });
  </code></pre>
  
  <p>I'm trying to create a new user whilst also authenticating with Passport.js.
  the log shows that <code>req.body</code> is undefined. I do not understand why this is the case. Could someone explain? </p>