title: passport User is not a function
body: <p>I keep getting the same error "User is not a function" when I call my API method.</p>
  
  <p>Has anybody got an ideas why this might be.</p>
  
  <p>Api method:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//need to export the api methods.
  var User = require('../models/user');
  var passport = require('passport');
  
  module.exports.create = function(req, res) {
    //TODO: error checking.
    var user = new User();
    console.log(req);
    user.firstName = req.body.firstName;
    user.secondName = req.body.secondName;
    user.email = req.body.email;
  
    user.setPassword(req.body.password);
  
    user.save(function(err) {
      res.status(200);
    });
  };</code></pre>
  </div>
  </div>
  </p>
  
  <p>user model:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>var mongoose = require('mongoose');
  var crypto = require('crypto');
  
  var userSchema = new mongoose.Schema({
    email: {
      type: String,
      unique: true,
      required: true
    },
    firstName: {
      type: String,
      required: true
    },
    lastName: {
      type: String,
      required: true
    },
    hash: String,
    salt: String
  });
  
  userSchema.methods.setPassword = function(password){
  };
  
  userSchema.methods.validPassword = function(password) {
  };
  
  mongoose.model('User', userSchema);</code></pre>
  </div>
  </div>
  </p>
  
  <p>Let me know if I need to enter any more files.</p>
  
  <p>Thanks</p>