fix(oauth2): compare accountId as forced string to prevent duplicates#3815
Closed
cemreinanc wants to merge 2 commits into
Closed
fix(oauth2): compare accountId as forced string to prevent duplicates#3815cemreinanc wants to merge 2 commits into
cemreinanc wants to merge 2 commits into
Conversation
|
@cemreinanc is attempting to deploy a commit to the better-auth Team on Vercel. A member of the Team first needs to authorize it. |
better-auth
@better-auth/cli
@better-auth/expo
@better-auth/sso
@better-auth/stripe
commit: |
Contributor
There was a problem hiding this comment.
cubic analysis
No issues found across 1 file. Review in cubic
Kinfe123
approved these changes
Aug 5, 2025
himself65
reviewed
Aug 5, 2025
Contributor
There was a problem hiding this comment.
What is the real case causing the accountId to be a number? Could there be a deeper issue behind this? since the type annotation around is all string
Contributor
There was a problem hiding this comment.
I realized that issue is from https://github.com/better-auth/better-auth/pull/3816/files#diff-16e9f39c92f582849ffc6ba9be9b14f8f04a8137bf025e3c876159c01d254564R307 if getUserInfo returns the number. we don't give any error about this
Contributor
|
closed in favor of #3816 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
in oauth2/link-account.ts file:
accountIdreturns as a string from database but other one returns as a number from the endpoint. So they dont align and causehasBeenLinkedto beundefined.in line 46 comparing like this
a.accountId === String(account.accountId)seems like solved the issue.Closes #3814
Summary by cubic
Fixed an issue where OAuth account linking could create duplicate accounts by ensuring accountId is always compared as a string.