Skip to content

Commit

Permalink
Rate limit updates
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Apr 27, 2024
1 parent 79d6f64 commit d7d6ff0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/backend/src/routers/change_username.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class EdgeRateLimitService extends BaseService {
_construct () {
this.scopes = {
['login']: {
limit: 3,
limit: 10,
window: 15 * MINUTE,
},
['signup']: {
Expand Down

0 comments on commit d7d6ff0

Please sign in to comment.