Conversation
📝 WalkthroughWalkthroughRefactors email-change token generation to use a signed payload via a new EmailChangeTokenGenerator (subclassing PasswordResetTokenGenerator) and adds comprehensive unit tests plus frontend email-change confirmation UI and translations. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🧹 Preview Environment Cleaned UpThe preview environment for this PR has been destroyed.
Cleanup triggered by PR close at 2026-02-06T13:16:29Z |
# Conflicts: # users/services/common.py
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@front_end/src/app/`(main)/accounts/change-email/layout.tsx:
- Around line 15-18: The UI currently renders raw error.message in layout.tsx
which can leak internals and isn't localized; replace the visible text with a
localized, generic message via the i18n function t (e.g.,
t("emailChangeErrorDetails") or t("unknownError")) and stop outputting
error.message directly in the <p> element, and if you still need the raw error
for debugging, log it conditionally (only in development) using
console.debug/console.error when NODE_ENV === "development" or similar,
referencing the same error variable and the t function to locate where to
change.
In `@front_end/src/app/`(main)/accounts/change-email/page.tsx:
- Around line 5-13: In ChangeEmailPage, avoid throwing during server render:
normalize props.searchParams.token (which may be string | string[] | undefined)
by resolving props.searchParams, then coerce token to a single string (e.g., if
Array take the first element) or null/undefined if absent, remove the throw new
Error("Missing token parameter"), and pass the normalized token down to the
client component so the client-side component can handle missing/invalid tokens
gracefully; update references in ChangeEmailPage to use the normalizedToken
variable (or similar) instead of token.
🧹 Nitpick comments (1)
front_end/src/app/(main)/accounts/change-email/client.tsx (1)
18-22: Userouter.replace()instead ofrouter.push()to prevent back-button returns to the token URL.
replace()replaces the current history entry rather than adding a new one, which improves UX by preventing the user from navigating back to this intermediate confirmation page. Note: whilereplace()avoids a history entry, it does not prevent the token from being exposed via server logs, caches, or referrer headers. For stronger security, consider consuming the token server-side and redirecting to a clean URL.Suggested change
- .then(() => router.push("/accounts/settings/account?emailChanged=true")) + .then(() => router.replace("/accounts/settings/account?emailChanged=true"))
https://www.notion.so/metaculus/Expire-Password-Reset-Links-on-Email-Change-f1613821497f4e33bbbe503b9a059dad?v=2f76aaf4f1018099baa0000cdc0a6471&source=copy_link
Summary by CodeRabbit
Tests
Refactor
New Features
Localization