title: Passport authentication not working in sails.js application
body: <p>I have a Sails JS application. I am trying to setup authentication using Passport.js authentication layer <a href="https://github.com/kasperisager/sails-generate-auth" rel="nofollow">sails-generate-auth</a>. I have configured my app by following the steps given in their documentation. </p>
  
  <p>But when I lift my sails app, authentication is not working. I am able to access the controllers, even when I am not logged in (It's not redirecting to my login page).</p>
  
  <p>I added a <code>console.log</code> statement in <code>api/policies/passport.js</code> as follows:</p>
  
  <pre><code>module.exports = function (req, res, next) {
    passport.initialize()(req, res, function () {
      passport.session()(req, res, function () {
        res.locals.user = req.user;
        console.log(req.user); // added by me
        next(); 
      });
    });
  };
  </code></pre>
  
  <p>Now, when I access controllers before login or after logout, its printing <code>undefined</code>. But when I am logged in, its printing my user data. Any idea why it is not checking for authentication?</p>
  
  <p>I am using local authentication strategy and I have commented out all others (twitter, facebook...)</p>