[GH-ISSUE #1122] Prefer using accountId over email to find OAuth user #17238

Closed
opened 2026-04-15 15:16:29 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @DIYgod on GitHub (Jan 4, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1122

Is this suited for github?

  • Yes, this is suited for github

Related to #959 #963

Describe the solution you'd like

In #963, the logic for finding OAuth users has been changed from searching only based on email to prioritizing email search, and if not found, searching based on accountId and providerId. This is a very useful step that solves the problem of users not being able to log in to their accounts due to changing the email of a third-party account.

However, there is still a problem: if the user's third-party account email changes from a@example.com to b@example.com, and b@example.com has already been registered in better auth, they will still not be able to log in to the previously linked a@example.com.

Describe alternatives you've considered

I propose to change the logic for finding OAuth users to prioritize searching by accountId and providerId, and if not found, then search by email.

Additional context

No response

Originally created by @DIYgod on GitHub (Jan 4, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1122 ### Is this suited for github? - [X] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Related to #959 #963 ### Describe the solution you'd like In #963, the logic for finding OAuth users has been changed from searching only based on email to prioritizing email search, and if not found, searching based on accountId and providerId. This is a very useful step that solves the problem of users not being able to log in to their accounts due to changing the email of a third-party account. However, there is still a problem: if the user's third-party account email changes from a@example.com to b@example.com, and b@example.com has already been registered in better auth, they will still not be able to log in to the previously linked a@example.com. ### Describe alternatives you've considered I propose to change the logic for finding OAuth users to prioritize searching by accountId and providerId, and if not found, then search by email. ### Additional context _No response_
GiteaMirror added the locked label 2026-04-15 15:16:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#17238