Skip to content

fix(console): send the verification email from the verify page - #14286

Merged
HarshMN2345 merged 7 commits into
mainfrom
fix/console-verify-email-send
Oct 9, 2026
Merged

HarshMN2345 merged 7 commits into
mainfrom
fix/console-verify-email-send

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

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:

  • Unverified account signing in, main: lands on /verify-email, no POST /v1/account/verifications/email, nothing in the inbox.
  • Same, this PR: one POST /v1/account/verifications/email (201), "Verification email sent" toast, the email arrives.
  • Password sign-up, this PR: one POST /v1/account/verifications/email (201).
  • Resend still sends, and opening a link with userId and secret only confirms (PUT).

Before / after recordings:

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

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.
@luxor-code-review

luxor-code-review Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

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 sentVerifications Set backed by a sessionStorage marker to survive remounts and reloads, and users can still trigger a manual resend. Verification from the emailed link (userId + secret) and redirect handling are unchanged.

Files Change
apps/console/src/routes/_auth/sign-up.tsx Drops the inline verification send after account creation, relying on the verify-email page to send.
apps/console/src/routes/_auth/verify-email.tsx Adds auto-send-on-mount with Set/sessionStorage dedupe, a manual resend button, and loading/error handling.

Reviewed commit: d6ccd52

@ghost

ghost commented Oct 9, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The previously reported remount/pending-state issue is fixed, and I found no other actionable defects in the incremental changes.

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 useIsMutating to preserve its pending UI state across remounts, while replacing the deferred send timer with a guarded immediate effect send.

Verdict New comments Fixed Still open
💬 Commented 0 1 0

[!NOTE]

Newer commits exist (`9d945d4`) and will be reviewed. This review is of `f28f21a` and does not approve it.
📂 Walkthrough · 2
File Change
apps/console/src/routes/_auth/sign-up.tsx Removes password sign-up's direct verification-email request so the verification page owns sending.
apps/console/src/routes/_auth/verify-email.tsx Sends verification emails once per account, preserves resend and confirmation flows, and tracks resend pending state from the mutation cache across remounts.
✅ Fixed since the last review · 1
  • Track pending sends across mutation-observer remounts · apps/console/src/routes/_auth/verify-email.tsx:240

Merged main (3c66876); no changes to this PR's code since f28f21a · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +73 to +84
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
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · See the inline comments. Summary

@HarshMN2345 HarshMN2345 changed the title Fix: verify email page says a link was sent without sending one fix(console): send the verification email from the verify page Oct 9, 2026
HarshMN2345 and others added 3 commits October 9, 2026 14:07
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.
@HarshMN2345
HarshMN2345 merged commit f4a362d into main Oct 9, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant