我使用var basicAuth = require('basic-auth');
,我需要检查用户是否获得授权。
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.');
}
}
};