title: Express resources with authentication middleware?
body: <p><a href="http://passportjs.org/" rel="nofollow">Passport.js</a> offers great authentication for node.js and Express including a middleware solution:</p>
  
  <pre><code>ensureAuthenticated = function(req, res, next) {
    if (req.isAuthenticated()) {
      return next();
    }
    return res.redirect("/login");
  };
  </code></pre>
  
  <p>How can I use this middleware in the express-resource module? Unfortunately,</p>
  
  <pre><code>app.resource('users', ensureAuthenticated, require('./resources/users'));
  </code></pre>
  
  <p>doesn't work.</p>