Repository navigation
fix(auth): Google sign-in with an email another account holds is refused, not a 500 - #1106
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Legacy
AuthService.LoginWithGoogleAsynccreated (or re-emailed) a user straight intoix_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 answersEmailTaken); the proper 409 arrives withIAuthServiceat M5.1.Changes
AuthService.GetOrCreateUserAsync→User?; oneSaveOrEmailTakenAsyncaround bothSaveChangesAsynccalls.AuthServiceconstructor gains an optionalProviderTokens? 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 otherDbUpdateExceptionstill throws.Tests
UnitTests auth classes 36/36,
dotnet formatclean, solution builds.Rollback plan
Revert the commit; the only behaviour change is 500 → 401 on that one path.
🤖 Generated with Claude Code