Repository navigation
Clear pending recovery tokens when the account email changes - #14347
Conversation
Account and Users email updates now drop outstanding recovery, verification, magic-URL, and email OTP tokens for that user, then purge the user document cache. Sessions are left unchanged. Co-authored-by: Jake Barnby <[email protected]>
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
Both email-update endpoints now delete the user's recovery, OTP, email-verification, magic-url, and email-type tokens when the email changes, then purge the cached user document, so stale recovery links stop working after an address change. New e2e tests assert that a previously issued recovery secret returns 401 after the change and that a fresh recovery still completes with 200.
Reviewed commit: a5f1efe |
🟢 Tier S · Ready to merge
Email updates now remove outstanding recovery, verification, magic-URL, and email OTP tokens for the user. Token creation and email updates are serialized around the user record so a token for an outdated address cannot survive a concurrent change. E2E coverage exercises both email-update routes and verifies stale tokens fail while sessions remain valid.
📂 Walkthrough · 4
Reviewed |
Co-authored-by: Jake Barnby <[email protected]>
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
The findings that requested changes are resolved. See the summary comment for what is still open.
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Verification, verification OTP, magic URL, and email OTP now re-read the user under the same row lock as email updates before inserting a token. A token is stored only when the address still matches. Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
…kens-on-email-change Clear pending recovery tokens when the account email changes (cherry picked from commit e7dea57)
…rite#14347) (cherry picked from commit e7dea57)
What does this PR do?
When an account email is updated (
PATCH /v1/account/emailorPATCH /v1/users/:userId/email), outstanding recovery tokens stay attached to the user. Those tokens were created for the previous address, so they no longer match the current account email.This change deletes the user's pending recovery tokens after a successful email update, along with other email-bound tokens (recovery OTP, email verification, magic URL, and email OTP). Sessions are left as they are. The user document cache is purged the same way other token deletions already do.
Test Plan
Related PRs and Issues
Checklist