Skip to content

fix(auth): Google sign-in with an email another account holds is refused, not a 500 - #1106

Merged
mrviduus merged 3 commits into
mainfrom
fix/google-sign-in-email-taken
Nov 3, 2026
Merged

mrviduus merged 3 commits into
mainfrom
fix/google-sign-in-email-taken

Conversation

@mrviduus

@mrviduus mrviduus commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Summary

Legacy AuthService.LoginWithGoogleAsync created (or re-emailed) a user straight into ix_users_email, so a Google account whose email another TextStack account already holds answered 500. It now answers null → 401 with a Warning log (SaveOrEmailTakenAsync: DbUpdateException + IsUniqueViolation()), for a new subject and for a known subject whose Google email changed. Any other save failure still throws. Found by the M2.5b reviews (V2 already answers EmailTaken); the proper 409 arrives with IAuthService at M5.1.

Changes

  • AuthService.GetOrCreateUserAsync → User?; one SaveOrEmailTakenAsync around both SaveChangesAsync calls.
  • AuthService constructor gains an optional ProviderTokens? providers (tests fake the verifier; production unchanged).
  • tests/TextStack.UnitTests/GoogleSignInEmailTakenTests.cs: new subject with a taken email → null; known subject whose new email is taken → null; any other DbUpdateException still throws.

Tests

UnitTests auth classes 36/36, dotnet format clean, solution builds.

Rollback plan

Revert the commit; the only behaviour change is 500 → 401 on that one path.

🤖 Generated with Claude Code

mrviduus and others added 3 commits November 2, 2026 11:38
…sed, not a 500

The create and the email update both hit ix_users_email; the unique violation
is now a null result (the endpoint answers 401) with a warning log. AuthService
takes an optional ProviderTokens so the verifier can be faked in unit tests.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@mrviduus
mrviduus merged commit 58953db into main Nov 3, 2026
11 checks passed
@mrviduus
mrviduus deleted the fix/google-sign-in-email-taken branch November 3, 2026 05:10
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