Skip to content

Commit

Permalink
Add ratelimit for /confirm-email
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Apr 24, 2024
1 parent 1eac147 commit b2e72ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/backend/src/routers/confirm-email.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ router.post('/confirm-email', auth, express.json(), async (req, res, next)=>{
if(!req.body.code)
req.status(400).send('code is required');

const svc_edgeRateLimit = req.services.get('edge-rate-limit');
if ( ! svc_edgeRateLimit.check('confirm-email') ) {
return res.status(429).send('Too many requests.');
}

// Modules
const db = req.services.get('database').get(DB_WRITE, 'auth');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class EdgeRateLimitService extends BaseService {
limit: 10,
window: HOUR,
},
['confirm-email']: {
limit: 10,
window: HOUR,
},
['send-pass-recovery-email']: {
limit: 10,
window: HOUR,
Expand Down

0 comments on commit b2e72ad

Please sign in to comment.