Rate limit updates

This commit is contained in:
KernelDeimos 2024-04-26 21:01:52 -04:00
parent 79d6f64451
commit d7d6ff0cca
2 changed files with 6 additions and 1 deletions

View File

@ -54,6 +54,11 @@ module.exports = eggspress('/change_username', {
if(await username_exists(req.body.new_username))
throw APIError.create('username_already_in_use', null, { username: req.body.new_username });
const svc_edgeRateLimit = req.services.get('edge-rate-limit');
if ( ! svc_edgeRateLimit.check('change-email-start') ) {
return res.status(429).send('Too many requests.');
}
const db = Context.get('services').get('database').get(DB_WRITE, 'auth');
// Has the user already changed their username twice this month?

View File

@ -8,7 +8,7 @@ class EdgeRateLimitService extends BaseService {
_construct () {
this.scopes = {
['login']: {
limit: 3,
limit: 10,
window: 15 * MINUTE,
},
['signup']: {