improvement(oauth): added random identifier in unnused accountId to bypass betterauth unique constraint#2807
Merged
waleedlatif1 merged 2 commits intostagingfrom Jan 14, 2026
Merged
Conversation
…ypass betterauth unique constraint
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR resolves the The solution has two parts:
The Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant BetterAuth
participant OAuth Provider
participant DB
User->>BetterAuth: Connect OAuth Account
BetterAuth->>OAuth Provider: Initiate OAuth Flow
OAuth Provider-->>BetterAuth: Return Profile Data
Note over BetterAuth: Append random UUID to accountId
BetterAuth->>DB: Query existing account by userId and providerId
alt Account exists
DB-->>BetterAuth: Found existing account
BetterAuth->>DB: Update account tokens and accountId
Note over DB: Unique constraint on (userId, providerId)<br/>prevents duplicates
else Account does not exist
DB-->>BetterAuth: No existing account
BetterAuth->>DB: Insert new account with random accountId
end
DB-->>BetterAuth: Success
BetterAuth-->>User: Account connected
|
Collaborator
Author
|
@greptile |
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
idso we can just append a randomUUID to itaccount_already_linked_to_different_userissueType of Change
Testing
Tested manually
Checklist