Hello,
I am asking how to properly temporarily throttle certain Flarum API routes. Namely, we at FreeFlarum have found that api/forgot
can be quite easily spammed with POST
requests which results in E-mail spam.
The question is, how can we throttle certain routes so that they won't be spammed? Say I want to add a 5 minute cooldown between sending forgotten password requests and test mail request.
So far, we are using this code (for test mail), but that throttles the test mail permanently, making it disfunctional - we want similar temporary cooldown for forgotten password requests:
[...]
(new Flarum\Extend\ThrottleApi)->set('throttleMailTests', function ($request) {
if ($request->getAttribute('routeName') === 'mailTest') {
return true;
}
}),
[...]
Thanks