Repository navigation
fix: enforce password-reset rate limit and map to 429 - #1336
Conversation
|
@Ajibola6921 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
e6848f7 to
b60ca7d
Compare
|
Security check: this PR contains malware (the PolinRider campaign) and can't be merged as it is. Our automated scan flagged these files on your branch:
These changes are not part of your fix. They hide code that runs automatically on the machine of anyone who opens or installs the project (padded/obfuscated code in config files, Please:
Thanks! |
Strips the payload this branch picked up (deleted api.js, unhooked package.json). No functional change to the branch's own work.
Overview
This PR fixes the password-reset rate limiter so that a
allowed: falseresult actually rejects the request instead of being swallowed by the surroundingtry/catch. It also mapsPasswordResetRateLimitedErrorto a 429 response with aRetry-Afterheader, replacesconsole.errorwith the structured logger, and adds regression tests covering both the limited path and the limiter-error policy.Related Issue
Changes
🔒 Rate-limit enforcement in
PasswordResetService.requestResetsrc/services/passwordResetService.tsallowedcheck outside thetryblock so a rate-limited result is no longer caught by the fail-open handler.checkRateLimitcall is wrapped; limiter infrastructure errors are logged atwarnwith a metric and follow the documented fail-open policy.console.errorwith the structured logger.🚦 Route mapping
src/routes/passwordReset.tsPasswordResetRateLimitedErrorto HTTP 429 with aRetry-Afterheader.🧪 Tests
[MODIFY]
src/services/passwordResetService.test.tsallowed: false, no token row is inserted and no email is sent (fails onmaster, passes after the fix).checkRateLimitthrows.[MODIFY]
src/routes/passwordReset.test.tsRetry-Afterheader when the service raisesPasswordResetRateLimitedError.Verification Results
allowed: false, no token row is inserted, no email is sent, and the route returns 429 withRetry-Afterwarnwith metric; test addedsrc/services/passwordResetService.test.tsandsrc/routes/passwordReset.test.tsmaster(an email is sent while limited) and passes after the fixCloses #1266