title: Sails.js 0.10 and passport
body: <p>I was fiddling with sails.js and passport. Seems they are mend to be used together.</p>
  
  <p>I have made the user models available in de db. And I am able to use the authentication by bcryptjs. This works, but dearly want to like to automatically authenticate every call, and mostly socket.io blueprint calls.</p>
  
  <p>Still,  I am searching for an elegant method to enable the sails.js way of integrating passport.
  There are many examples, but seem a bit out-dated, not sure.</p>
  
  <p>Important is the sockets. They need to be authenticated.</p>
  
  <p>For e.g. every io.socket CRUD method, would be nice.</p>
  
  <p>Kind regards </p>
  
  <hr>
  
  <p>I found a link (<a href="http://www.bearfruit.org/2014/07/21/tutorial-easy-authentication-for-sails-js-apps/" rel="nofollow">http://www.bearfruit.org/2014/07/21/tutorial-easy-authentication-for-sails-js-apps/</a>) that's pointing me in the right direction, but still not clear how this is reflected in for instance controllers</p>
  
  <p>What I am trying to manage, is to have the custom api calls authenticated before they are called (configured in routes.js or by means of blueprints).</p>
  
  <p>e.g: </p>
  
  <p>OrderController:</p>
  
  <pre><code>module.exports = {
  
  placeOrder: function (req, res) {
    if (true === req.isSocket) {
      // Pseudo code: 
      if (passport.authenticated(['user','admin'])) {
        Order.save();
      }
  
      // end pseudo code
    }
  }
  
  }
  </code></pre>
  
  <p>How should/is the above method secured, and I am I able to use for instance user-roles here?</p>