Skip to content

fix(auth): tell users why a duplicate sign-in was rejected - #5047

Closed
Celant wants to merge 1 commit into
v33from
fix/duplicate-account-email-conflict
Closed

Celant wants to merge 1 commit into
v33from
fix/duplicate-account-email-conflict

Conversation

@Celant

@Celant Celant commented Aug 19, 2026

Copy link
Copy Markdown
Member

Context

Paired with openfrontio/infra#531. The API no longer creates a second account when a Google/Discord sign-in carries a verified email that already belongs to a player — it bounces back with #login=email_exists instead. Without this PR the user is redirected home with no feedback at all and no idea why nothing happened.

Change

  • LoginResult.ts — consumeLoginResult() reads the one-shot login= router arg and strips it from the URL so a refresh doesn't replay it. Mirrors how the existing link= results are consumed.
  • AccountModal renders it as a dismissible banner above the sign-in buttons, so the next action is already on screen.
  • One new en.json key. No other translation files touched.

Copy

You already have an account with this email. Sign in to it, then link this account in settings.

It deliberately doesn't name which provider the existing account uses. The visitor has only proven control of the email address, not of the account, so we confirm an account exists and stop there.

Note on scope

No fallback for a return URL missing #modal=account. BaseModal.open() always calls modalRouter.syncOpened() before the user can reach a login button — including the showPage("page-account") paths from Matchmaking/ClanModal/SinglePlayerModal — so the arg always arrives. A fallback would have been untested dead code.

Testing

TDD: tests written and watched fail first.

  • consumeLoginResult: returns the result, ignores unrecognised values, strips the param, clears the hash when it was the only param
  • AccountModal rendering: banner shows after a rejected sign-in, absent on an ordinary open, dropped on reopen

Full suite: 234 files / 2749 tests passing, tsc --noEmit and lint clean.

Landing on main too

Same change ported to main in a separate PR — AccountModal.ts has diverged there (GoogleLinkResult.ts / AccountSettingsModal.ts extracted), so it needed a real resolution rather than a clean pick.

🤖 Generated with Claude Code

The API no longer creates a second account when a Google/Discord sign-in
carries a verified email that already belongs to a player — it bounces
back with `#login=email_exists` instead. Surface that.

consumeLoginResult() reads the one-shot `login=` router arg and strips it
from the URL so a refresh doesn't replay it, mirroring how the existing
`link=` results are consumed. AccountModal renders it as a dismissible
banner above the sign-in buttons, so the next action is already on screen.

The copy deliberately doesn't name which provider the existing account
uses: the visitor has only proven control of the email address, not of
the account, so we say an account exists and stop there.

No fallback for a return URL without `#modal=account` — BaseModal.open()
always syncs the router hash before the user can reach a login button.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 80243992-1f78-447e-8df1-0974f7499e66

📥 Commits

Reviewing files that changed from the base of the PR and between bebc953 and 9fe66f0.

📒 Files selected for processing (5)
  • resources/lang/en.json
  • src/client/AccountModal.ts
  • src/client/LoginResult.ts
  • tests/client/AccountModal.rendering.test.ts
  • tests/client/LoginResult.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

The change adds one-shot handling for the email_exists login result. It removes the result from the URL, stores it in AccountModal, and displays a localized dismissible warning. Tests cover URL cleanup and modal state resets.

Changes

Login error flow

Layer / File(s) Summary
Consume login result
src/client/LoginResult.ts, tests/client/LoginResult.test.ts
LoginResult recognizes email_exists. consumeLoginResult removes the consumed hash parameter while preserving other parameters. Tests cover valid, missing, unsafe, and unsupported values.
Render login error
src/client/AccountModal.ts, resources/lang/en.json, tests/client/AccountModal.rendering.test.ts
AccountModal consumes login results on open, resets the error state, and renders a dismissible localized warning. Rendering tests cover rejected sign-ins, ordinary opens, and reopening.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 9fe66

This localized change adds user feedback for rejected duplicate sign-ins and clears the one-shot message after use; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant RouterArguments
  participant AccountModal
  participant consumeLoginResult
  participant LoginErrorBanner
  RouterArguments->>AccountModal: open with login=email_exists
  AccountModal->>consumeLoginResult: consume login result
  consumeLoginResult-->>AccountModal: return email_exists
  AccountModal->>LoginErrorBanner: render localized warning
  LoginErrorBanner-->>AccountModal: dismiss warning
Loading

Possibly related PRs

Suggested labels: UI/UX

Suggested reviewers: ryanbarlow97

Poem

A login result rides the hash,
Then quietly leaves the page.
The modal shows a warning clear,
With dismissible message near.
Reopen it, and state resets.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main authentication change: explaining duplicate sign-in rejection.
Description check ✅ Passed The description directly explains the duplicate sign-in issue, implementation, user-facing message, tests, and validation results.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@evanpelle

Copy link
Copy Markdown
Collaborator

I'll cherry pick the one from main into v33

@evanpelle evanpelle closed this Aug 19, 2026
@github-project-automation github-project-automation Bot moved this from Triage to Complete in OpenFront Release Management Aug 19, 2026
evanpelle pushed a commit that referenced this pull request Aug 19, 2026
… of #5047) (#5048)

## Context

`main` port of #5047 — same change, resolved against main's refactors.
Paired with openfrontio/infra#531.

The API no longer creates a second account when a Google/Discord sign-in
carries a verified email that already belongs to a player; it bounces
back with `#login=email_exists`. This surfaces that to the user instead
of redirecting them home with no feedback.

## Change

- `LoginResult.ts` — `consumeLoginResult()` reads the one-shot `login=`
router arg and strips it from the URL so a refresh doesn't replay it.
Sits alongside the existing `GoogleLinkResult.ts` and follows the same
shape.
- `AccountModal` renders a dismissible banner above the sign-in buttons.
- One new `en.json` key.

## Copy

> You already have an account with this email. Sign in to it, then link
this account in settings.

It deliberately **doesn't name which provider** the existing account
uses — the visitor has only proven control of the email address, not of
the account.

## Port notes

The cherry-pick from `v33` conflicted; resolved toward main's structure
rather than forcing it:

- kept main's `consumeGoogleLinkResult(args)`, dropped v33's
`handleLinkResult(args)`
- did **not** reintroduce `consentBusy`, `renderLogoutButton`, or
`account_modal.log_out` — main has moved those into
`AccountSettingsModal`
- import order fixed for main's `./utilities/PlayerProfileUrl` path

Resulting diff is identical in shape to #5047, and `LoginResult.ts` is
byte-identical across both branches.

## Testing

Full suite: **278 files / 3227 tests passing**, `tsc --noEmit` and lint
clean.

⚠️ Unrelated heads-up: `tests/client/InventoryModal.test.ts` fails
intermittently under full-suite load on pristine `origin/main` (verified
with none of this branch's code present — 3-4 failures, different subset
each run, 21/21 in isolation). It happened not to trip on the final run
here, but it's flaky on main independent of this PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
evanpelle pushed a commit that referenced this pull request Aug 19, 2026
… of #5047) (#5048)

`main` port of #5047 — same change, resolved against main's refactors.
Paired with openfrontio/infra#531.

The API no longer creates a second account when a Google/Discord sign-in
carries a verified email that already belongs to a player; it bounces
back with `#login=email_exists`. This surfaces that to the user instead
of redirecting them home with no feedback.

- `LoginResult.ts` — `consumeLoginResult()` reads the one-shot `login=`
router arg and strips it from the URL so a refresh doesn't replay it.
Sits alongside the existing `GoogleLinkResult.ts` and follows the same
shape.
- `AccountModal` renders a dismissible banner above the sign-in buttons.
- One new `en.json` key.

> You already have an account with this email. Sign in to it, then link
this account in settings.

It deliberately **doesn't name which provider** the existing account
uses — the visitor has only proven control of the email address, not of
the account.

The cherry-pick from `v33` conflicted; resolved toward main's structure
rather than forcing it:

- kept main's `consumeGoogleLinkResult(args)`, dropped v33's
`handleLinkResult(args)`
- did **not** reintroduce `consentBusy`, `renderLogoutButton`, or
`account_modal.log_out` — main has moved those into
`AccountSettingsModal`
- import order fixed for main's `./utilities/PlayerProfileUrl` path

Resulting diff is identical in shape to #5047, and `LoginResult.ts` is
byte-identical across both branches.

Full suite: **278 files / 3227 tests passing**, `tsc --noEmit` and lint
clean.

⚠️ Unrelated heads-up: `tests/client/InventoryModal.test.ts` fails
intermittently under full-suite load on pristine `origin/main` (verified
with none of this branch's code present — 3-4 failures, different subset
each run, 21/21 in isolation). It happened not to trip on the final run
here, but it's flaky on main independent of this PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants