Windshaft-cartodb/lib/cartodb/api/middlewares/authorize.js
2018-04-09 18:08:56 +02:00

20 lines
542 B
JavaScript

module.exports = function authorize (authBackend) {
return function authorizeMiddleware (req, res, next) {
authBackend.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();
});
};
};