2018-08-01 14:56:31 +02:00
|
|
|
const RateLimit = require('koa2-ratelimit').RateLimit;
|
|
|
|
|
|
|
|
module.exports = async (ctx, next) => {
|
|
|
|
const message = ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.ratelimit' }] }] : 'Too many attempts, please try again in a minute.';
|
|
|
|
|
2018-08-08 14:29:10 +02:00
|
|
|
return RateLimit.middleware(Object.assign({}, {
|
2018-08-01 14:56:31 +02:00
|
|
|
interval: 1*60*1000,
|
|
|
|
max: 5,
|
|
|
|
prefixKey: `${ctx.request.url}:${ctx.request.ip}`,
|
|
|
|
message
|
2018-08-08 14:29:10 +02:00
|
|
|
}, strapi.plugins['users-permissions'].config.ratelimit))(ctx, next);
|
2018-08-01 14:56:31 +02:00
|
|
|
};
|