Prefer using accountId over email to find OAuth user #524

Closed
opened 2026-03-13 07:50:57 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @DIYgod on GitHub (Jan 4, 2025).

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). ### 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_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#524