fix(auth): rate limit profile updates - #313
Conversation
| } | ||
|
|
||
| export async function handleUpdateProfile(props: Args, { user }: Context) { | ||
| export async function handleUpdateProfile(props: Args, { user, connectionInfo }: Context) { |
| }); | ||
| } | ||
|
|
||
| import { consumeRateLimit } from '../rate-limit/rules'; |
There was a problem hiding this comment.
Please move the import statement to the top, follow clean code
|
|
||
| export async function createGuestUser() { | ||
| // TODO: add rate-limiting and captcha handling | ||
| import { Context } from '../methods/types'; |
There was a problem hiding this comment.
Please move import statement to the top
9dcb7c3 to
bce2c56
Compare
|
@aadityakumarsah why do we need a rate limit on |
bce2c56 to
65d551d
Compare
|
@omegascorp You are right. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e1d197e. Configure here.
|
@aadityakumarsah this branch seems to have the same issue as the other branches - it has unrelated changes |
c6c2fa6 to
1af3bfb
Compare

Summary
auth.rateLimits.updateProfilefor configuration overridesThis branch was rebuilt from current
mainand contains only the profile-update rate-limit change.Testing
npm run lint:checknpm run buildnpm testNote
Low Risk
Scoped to profile update mutation with conservative defaults; quota is not consumed on validation failures, limiting user impact.
Overview
Adds per-user rate limiting on profile updates so abusive or automated
updateProfiletraffic is capped like other auth actions.Default limits are 30 updates per 15 minutes and 200 per day per user, registered on the auth module’s rate-limit rules. Apps can tune them via
auth.rateLimits.updateProfileusing the same override/merge behavior as other auth buckets.handleUpdateProfilenow callsconsumeRateLimitwith bucketupdateProfileonly when there is a non-empty update to persist—after field validation, the optionalvalidateProfileUpdatehook, and handle uniqueness checks—so invalid or rejected requests do not burn quota. Tests cover defaults, overrides, and when the limit is (not) consumed.Reviewed by Cursor Bugbot for commit 1af3bfb. Bugbot is set up for automated code reviews on this repo. Configure here.