title: MongooseJS cannot retrieve data after saving it
body: <p>I have a simple ExpressJS app and I'm trying to add user authentication to it using passport, passport-local and passport-local-mongoose, but after I save a user's data on db, mongoose fails to retrieve it, although I can see the data through mongo cli.</p>
  
  <p>At the main express module I have:</p>
  
  <pre class="lang-js prettyprint-override"><code>// Passport session setup.
  var User = require("./models/user");
  passport.use(new LocalStrategy(User.authenticate()));
  passport.serializeUser(User.serializeUser());
  passport.deserializeUser(User.deserializeUser());
  </code></pre>
  
  <p>My User model module have:</p>
  
  <pre class="lang-js prettyprint-override"><code>var mongoose = require('mongoose');
  var Schema = mongoose.Schema;
  var passportLocalMongoose = require('passport-local-mongoose');
  
  
  // User Schema
  var User = new Schema({
    username: { type: String, required: true, unique: true },
    password: { type: String, required: true}
  });
  
  
  User.plugin(passportLocalMongoose);
  
  module.exports = mongoose.model('User', User);
  </code></pre>
  
  <p>At my routes module, I create a user with the following code:</p>
  
  <pre class="lang-js prettyprint-override"><code>router.post('/register', function(req, res) {
  
    var u = req.body.username;
    var p = req.body.password;
  
    console.log('Creating account for ' + u + ':' + p);
    // Store client on DB
    var usr = new User({ username: u, password: p });
    usr.save(function(err) {
      if(err) {
        console.log(err);
        return res.render('register', {title: 'Register', error: err.userMessage});
      } else {
        console.log('user: ' + usr.username + " saved.");
        passport.authenticate('local')(req, res, function () {
          return res.redirect('/dashboard');
        });
      }
    });
  
  });
  </code></pre>
  
  <p>But when I try to authenticate a user with the passport.authenticate method, mongoose cannot find the user at the db, as I can see on the mongoose logs:</p>
  
  <pre><code>Login request @  1422120637815
  Mongoose: users.findOne({ username: 'e@e.com' }) { fields: undefined }  
  </code></pre>
  
  <p>But at mongo cli I can see the data:</p>
  
  <pre><code>&gt; db.User.find()
  { "username" : "e@e.com", "password" : "123", "_id" : ObjectId("54c3d688fc71a4001db30612"), "__v" : 0 }
  </code></pre>