Repository navigation
fix(console): send the verification email from the verify page - #14286
Conversation
Only the password sign-up page sent a verification email, so every other way onto /verify-email (OAuth2, sign-in, the auth guard) said a link had been sent when none was. The page now sends the link itself, once per account per tab session so a reload does not mail another, and sign-up no longer sends its own. The resend button reads its pending state from the mutation cache: the automatic send starts in a mount effect, and a remount detaches the component's observer from it, leaving the button disabled.
… impersonators One sessionStorage value held only the last account sent a link, so switching accounts in a tab and reloading mailed the first account again. Each account now gets its own key. Impersonators cannot write to the account, so the automatic send would only fail with a read-only error toast; skip it while impersonating, like the other automatic account writes.
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
Sign-up no longer sends the verification email itself; the verify-email page now auto-sends it once per account on mount, using a module-level
Reviewed commit: d6ccd52 |
🟢 Tier S · Ready to merge
The verification page now sends an email for unverified accounts across password sign-up, OAuth, and other auth entry paths, while sign-up no longer sends a duplicate request. The page retains resend and confirmation-link handling, and it now reads resend pending state from the mutation cache so that state survives component remounts. The automatic send is guarded per account and starts directly from the page effect. Latest changes: The newest commits key the resend mutation and use
📂 Walkthrough · 2
✅ Fixed since the last review · 1
Merged |
There was a problem hiding this comment.
This PR removes the email-verification send from the sign-up flow and instead automatically sends it from the verify-email page via a mount effect, deduplicated by a module-level Set plus a sessionStorage marker.
Key findings
- 🟡 Auto-send claim persists after a failed send — verify-email.tsx:73
| function claimVerificationSend(accountId: string): boolean { | ||
| if (sentVerifications.has(accountId)) return false | ||
| sentVerifications.add(accountId) | ||
| const storageKey = `verify-email-sent:${accountId}` | ||
| try { | ||
| if (sessionStorage.getItem(storageKey)) return false | ||
| sessionStorage.setItem(storageKey, '1') | ||
| } catch { | ||
| // Storage can be unavailable (private mode); a reload then sends again. | ||
| } | ||
| return true | ||
| } |
There was a problem hiding this comment.
🟡 bug · medium
Auto-send claim persists after a failed send
claimVerificationSend marks the account as already sent — in the module-level sentVerifications set and in a verify-email-sent:${accountId} sessionStorage key — before the send is attempted (apps/console/src/routes/_auth/verify-email.tsx:73). The mount effect then fires resendMutation.mutate() without observing the result, and the mutation's onError only shows a toast, never releasing the claim. If createEmailVerification fails (rate limit, transient 5xx, network error), neither marker is rolled back: the effect never re-runs ([accountId] deps don't change), the Set survives remounts, and the sessionStorage key survives reloads for the whole tab session — so no automatic retry ever happens. The user lands on the verify-email page with no link in their inbox; recovery requires noticing an easily-missed toast and clicking the manual resend button.
📋 Prompt for AI Agents
In apps/console/src/routes/_auth/verify-email.tsx, make the auto-send claim revertible on failure. Add a releaseVerificationSend(accountId: string) helper next to claimVerificationSend (around line 73) that removes the account from the sentVerifications Set and, inside a try/catch, calls sessionStorage.removeItem('verify-email-sent:' + accountId). Thread the accountId into the mutation (e.g. pass it as the mutate variable) and call releaseVerificationSend in resendMutation's onError (around line 248) so a failed automatic send is retried on the next mount or page reload. Keep the manual resend button behavior and the successful-send dedupe intact.
Drop the sessionStorage claim and the mutation-cache pending state. The page sends once per account per page load from a deferred mount effect; StrictMode's throwaway mount cancels the timer, so the resend button stays bound to the request that actually runs. Sign-up's comment keeps main's wording.
A remount gives the page a new mutation observer that reports an in-flight automatic send as idle, so Resend could start a duplicate. The button now reads pending state from the mutation cache, which also covers StrictMode's effect replay, so the send no longer needs to be deferred.
What does this PR do?
Only the password sign-up page sent a verification email before opening
/verify-email. Every other route onto it (OAuth2 sign-up, sign-in, the auth guard, MFA, education join) showed "We've sent a verification link" with nothing sent, so people had to press resend to get an email.The page now sends the link itself, once per account per page load, and sign-up no longer sends its own, so a new password sign-up still gets exactly one email.
Test Plan
Console dev server against the local stack,
VITE_CONSOLE_USER_VERIFICATION=true:/verify-email, noPOST /v1/account/verifications/email, nothing in the inbox.POST /v1/account/verifications/email(201), "Verification email sent" toast, the email arrives.POST /v1/account/verifications/email(201).userIdandsecretonly confirms (PUT).Before / after recordings:
Related PRs and Issues
Checklist