如何检查用户是否获得授权? (基本-AUTH)

时间:2016-03-29 17:12:58

标签: node.js

我使用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.');
        }
    }
};

0 个答案:

没有答案
相关问题