...
|
...
|
@@ -45,21 +45,30 @@ module.exports = (req, res, next) => { |
|
|
limiter(qpsLimiter, captchaPolicy, context),
|
|
|
limiter(fakerLimiter, reporterPolicy, context)
|
|
|
]).then((results) => {
|
|
|
let allPass = true, exclusion = false;
|
|
|
let allPass = true, exclusion = false, policy = null;
|
|
|
|
|
|
_.forEach(results, (result) => {
|
|
|
if (typeof result === 'object') {
|
|
|
exclusion = result.exclusion || false;
|
|
|
if (typeof result === 'object' && !exclusion) {
|
|
|
exclusion = result.exclusion;
|
|
|
}
|
|
|
|
|
|
if (!excluded && !result) {
|
|
|
if (!excluded && typeof result === 'function') {
|
|
|
allPass = false;
|
|
|
}
|
|
|
|
|
|
if (typeof result === 'function') {
|
|
|
policy = result;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (allPass || exclusion) {
|
|
|
if (exclusion) {
|
|
|
return next();
|
|
|
} else if (!allPass && policy) {
|
|
|
policy(req, res, next);
|
|
|
} else {
|
|
|
return next();
|
|
|
}
|
|
|
|
|
|
}).catch((err) => {
|
|
|
logger.error(err);
|
|
|
return next();
|
...
|
...
|
|