title: How to check if user is authorized? (basic-auth)
body: <p>I'm using <code>var basicAuth  = require('basic-auth');</code> and I need to check if the user is authorized.</p>
  
  <pre><code>var basicAuth  = require('basic-auth');
  module.exports.authorize = function authorize(req, res, next) {
      var authInfo = basicAuth(req);
      bluebird.resolve().then(() =&gt; {
          if (!authInfo) { // Authorization header is not provided, send forbidden.
            throw new Error('Invalid username and/or password.');
          }
      }
  };
  </code></pre>