Repository navigation
fix(account): verify the account a provider sign-in adopts by email - #14283
Conversation
When an OAuth2 or ID-token sign-in matches an existing account by a provider-verified email, the account was adopted but kept emailVerification false. Accounts left unverified by an unfinished password sign-up or an invite then hit email verification right after signing in with Google, although Google had already vouched for the address. Mark the adopted account verified when its email is on the provider email's domain, which covers the canonical form stored for aliased addresses such as dotted Gmail.
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.
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
This PR changes both the console email-verification flow and the OAuth/OAuth2 account-adoption paths. On the backend, two adoption branches (legacy
Reviewed commit: 0bcbc7c |
🟢 Tier S · Ready to merge
OAuth2 and ID-token sign-in now mark an existing account verified when a verified provider email matches it on the same domain, including canonicalized aliases. The E2E tests cover the adopted-account behavior, and the latest commits clarify the provider-verification rationale in both flows. Latest changes: The newest commits revise the comments in both adoption branches to say the provider verified the address or its canonical form on the same domain.
📂 Walkthrough · 3
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
There was a problem hiding this comment.
The PR moves console email-verification link sending from sign-up to the /verify-email page with per-tab dedupe, and auto-marks adopted OAuth accounts verified when the provider-asserted email shares the domain.
Key findings
- 🟡 Verification send claimed before the send succeeds — verify-email.tsx:73
| function claimVerificationSend(accountId: string): boolean { | ||
| if (sentVerifications.has(accountId)) return false | ||
| sentVerifications.add(accountId) | ||
| try { | ||
| if (sessionStorage.getItem(SENT_VERIFICATION_STORAGE_KEY) === accountId) { | ||
| return false | ||
| } | ||
| sessionStorage.setItem(SENT_VERIFICATION_STORAGE_KEY, accountId) | ||
| } catch { | ||
| // Storage can be unavailable (private mode); a reload then sends again. | ||
| } | ||
| return true | ||
| } |
There was a problem hiding this comment.
🟡 bug · medium
Verification send claimed before the send succeeds
The auto-send claim is committed before the request is known to have succeeded: claimVerificationSend adds the account to the module Set and writes sessionStorage before resendMutation.mutate() fires (apps/console/src/routes/_auth/verify-email.tsx:73). On failure the onError handler only shows a toast, so a failed createEmailVerification (network error, rate limit) permanently consumes the automatic send for that account in this tab; a remount or full page load never retries. The user lands on a page implying a link was sent with no persistent error indication.
📋 Prompt for AI Agents
In apps/console/src/routes/_auth/verify-email.tsx, make the automatic verification send retryable: change claimVerificationSend (lines 73-85) into a check-only skip test, and move the sentVerifications.add(accountId) and sessionStorage.setItem(SENT_VERIFICATION_STORAGE_KEY, accountId) writes into resendMutation's onSuccess (around line 246) — e.g. invoke resendMutation.mutate(undefined, { onSuccess: () => commitVerificationSend(accountId) }) from the mount effect at lines 262-266. Why: the claim is currently consumed before the request resolves, so a failed automatic send is never retried on reload or remount and the user silently receives no email.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
composer audit fails on three advisories against 0.22.0 and earlier (stored XSS via DTD entities, mixed-case xlink:href skipping the <use> nesting check, DTD attribute declaration crash). 1.0.0 is not affected and keeps the minify()/sanitize() API the favicon endpoint uses.
… 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.
Both adoption tests, browser OAuth2 and ID token, now check that the adopted account comes back verified. Each assertion fails without the fix.
…mail-verification-5b88aa
The console half of this fix ships separately; this branch keeps the server change and its tests.
What does this PR do?
People who sign up with Google could land on "Verify your email" on Cloud even though Google had already vouched for the address.
A fresh Google user is already created verified from Google's
email_verifiedclaim. But when an unverified account with the same email already exists (an unfinished password sign-up, or the user an org invite creates), the OAuth2 callback and the ID-token session adopt that account on the verified-email match and leaveemailVerificationfalse.The email-match branch in both flows now marks the account verified when its stored email is on the provider email's domain, which covers the canonical form stored for aliased addresses (e.g.
[email protected]signing into[email protected]).Test Plan
Against an API container running this branch on the local stack:
testOAuthVerifiedEmailCanLinkToExistingAccount(browser OAuth2) andtestCreateIdTokenSessionEmailCollision(ID token) now assert the adopted account is verified. Each fails against main's code and passes here.AccountCustomClientTestpass (37 tests).Related PRs and Issues
Checklist