-
Notifications
You must be signed in to change notification settings - Fork 3.2k
improvement(oauth): added random identifier in unnused accountId to bypass betterauth unique constraint #2807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ypass betterauth unique constraint
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
Summary
idso we can just append a randomUUID to itaccount_already_linked_to_different_userissueType of Change
Testing
Tested manually
Checklist