title: How to find out last_login_date in passport/node js
body: <p>I have created a program using node js, passport, express and mongo, where first you have to register a user, and then you will be able to login. This is what my users schema looks like:</p>
  
  <pre><code>var UserSchema = mongoose.Schema({
      username: {
          type: String,
          required: true,
          unique: true,
          index: true
      },
      password: {
          required: true,
          type: String
      },
      creation_date: {
          type: Date,
          default: Date.now
      },
      last_login_date: {
          type: Date,
          default: Date.now
      }
  })
  </code></pre>
  
  <p>How do I find out when the user was last logged in? Ive been trying to figure this out for a while as I assume this will need to take place in the routes? This is my user route for login:</p>
  
  <pre><code>router.post('/login',
  passport.authenticate('local'),
    function(req, res) {
      res.json('Welcome ' + req.user.username);
  });
  </code></pre>
  
  <p>Has anyone managed to add a last_login_date for each user?</p>
  
  <p>Any clues would be helpful! </p>