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