mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
implement config option to disable ratelimit
This commit is contained in:
parent
68a4ec7729
commit
b75e8a1d10
@ -8,6 +8,15 @@ const { RateLimitError } = utils.errors;
|
|||||||
module.exports =
|
module.exports =
|
||||||
(config, { strapi }) =>
|
(config, { strapi }) =>
|
||||||
async (ctx, next) => {
|
async (ctx, next) => {
|
||||||
|
let ratelimitConfig = strapi.config.get('admin.ratelimit');
|
||||||
|
|
||||||
|
if (!ratelimitConfig || !ratelimitConfig.enabled) {
|
||||||
|
ratelimitConfig = {
|
||||||
|
enabled: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ratelimitConfig.enabled === true) {
|
||||||
const ratelimit = require('koa2-ratelimit').RateLimit;
|
const ratelimit = require('koa2-ratelimit').RateLimit;
|
||||||
|
|
||||||
const userEmail = toLower(ctx.request.body.email) || 'unknownEmail';
|
const userEmail = toLower(ctx.request.body.email) || 'unknownEmail';
|
||||||
@ -19,7 +28,10 @@ module.exports =
|
|||||||
handler() {
|
handler() {
|
||||||
throw new RateLimitError();
|
throw new RateLimitError();
|
||||||
},
|
},
|
||||||
...strapi.config.get('admin.ratelimit'),
|
...ratelimitConfig,
|
||||||
...config,
|
...config,
|
||||||
})(ctx, next);
|
})(ctx, next);
|
||||||
|
}
|
||||||
|
|
||||||
|
return next();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user