Windshaft-cartodb/lib/cartodb/middleware/authorize.js

20 lines
534 B
JavaScript
Raw Normal View History

2018-03-01 02:21:44 +08:00
module.exports = function authorize (authApi) {
return function authorizeMiddleware (req, res, next) {
authApi.authorize(req, res, (err, authorized) => {
req.profiler.done('authorize');
if (err) {
return next(err);
}
if(!authorized) {
err = new Error("Sorry, you are unauthorized (permission denied)");
err.http_status = 403;
return next(err);
}
return next();
});
};
};