2018-02-22 19:45:55 +08:00
|
|
|
module.exports = function timeoutLimits (metadataBackend) {
|
|
|
|
return function timeoutLimitsMiddleware (req, res, next) {
|
2018-06-05 19:21:56 +08:00
|
|
|
const { user, authorizationLevel } = res.locals;
|
2018-02-22 19:45:55 +08:00
|
|
|
|
|
|
|
metadataBackend.getUserTimeoutRenderLimits(user, function (err, timeoutRenderLimit) {
|
2018-02-22 19:48:39 +08:00
|
|
|
if (req.profiler) {
|
|
|
|
req.profiler.done('getUserTimeoutLimits');
|
|
|
|
}
|
|
|
|
|
2018-02-22 19:45:55 +08:00
|
|
|
if (err) {
|
|
|
|
return next(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
const userLimits = {
|
2018-06-05 19:21:56 +08:00
|
|
|
timeout: (authorizationLevel === 'master') ? timeoutRenderLimit.render : timeoutRenderLimit.renderPublic
|
2018-02-22 19:45:55 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
res.locals.userLimits = userLimits;
|
|
|
|
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|