Repository navigation
fix(auth): phone login for a user with an account under another phone - #218
Merged
Merged
Conversation
Delete the account the login created before the phone moves to the user's older account, so accounts.phone stays unique. Closes #213. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Closes #213.
loginWithPhonecreates an account for the phone, thensaveLoggedInUserfinds the user's older account byuser_id(a QRuser:<id>account or an old number) and moved the phone onto it before deleting the new account.accounts.phoneisUNIQUE, so the update threw and the login failed with a second account left behind.The new account is now deleted first. The phone belonged only to that account (it was found by
getByPhoneor created with it), so the update can't conflict afterwards, and no transaction is needed: a crash between the two statements leaves the older account untouched and no duplicate.The test runs on the real
accountsschema (createTestDatabase()) and failed before the fix withUNIQUE constraint failed: accounts.phone.Checks:
bun run check,bun run test,bun run test:e2e,bun run build.🤖 Generated with Claude Code