[GH-ISSUE #146] Linking credentials to an existing social account results in “User already exists” #16778

Closed
opened 2026-04-15 14:44:48 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @PawelPotempa on GitHub (Oct 11, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/146

Currently, if a user signs in using social login (I’ve tested with Google), and then attempts to create a credentials-based account with the same email, a 400 User already exists error is returned instead of linking the accounts. This works fine in the reverse scenario, where a social login is attached to an existing credentials-based account.

I’m not sure if this is the intended behavior, but I wanted to raise it in case it’s an issue. Apologies if there’s something I’m missing!

Originally created by @PawelPotempa on GitHub (Oct 11, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/146 Currently, if a user signs in using social login (I’ve tested with Google), and then attempts to create a credentials-based account with the same email, a `400 User already exists` error is returned instead of linking the accounts. This works fine in the reverse scenario, where a social login is attached to an existing credentials-based account. I’m not sure if this is the intended behavior, but I wanted to raise it in case it’s an issue. Apologies if there’s something I’m missing!
GiteaMirror added the lockedbug labels 2026-04-15 14:44:48 -05:00
Author
Owner

@Bekacru commented on GitHub (Oct 11, 2024):

yeah, that’s intentional. To add a credential account, use the user.setPassword method instead. It'll set the password and create a credential account for the user.

<!-- gh-comment-id:2407882973 --> @Bekacru commented on GitHub (Oct 11, 2024): yeah, that’s intentional. To add a credential account, use the `user.setPassword` method instead. It'll set the password and create a credential account for the user.
Author
Owner

@PawelPotempa commented on GitHub (Oct 11, 2024):

Got it, thanks for the clarification! However, this raises a question regarding user experience.

If I understand the user.setPassword method correctly, it only makes sense to use it when the user is already signed in. Wouldn’t it make sense to also allow the user to create a credential account via the password reset flow, if they initially signed up using a social login? If no user with the email exists, it would continue to ignore the reset attempt, as it currently does.

Right now, if a user inputs their social account email in the password reset form, the email with the reset link is sent, the user can visit the link and attempt to reset the password, however, the reset attempt fails because no credential account exists. It might feel more intuitive if this process allowed the user to set up a password, creating a credential account in the process. I believe some platforms (e.g., Spotify) use a similar flow, though I haven't checked recently.

<!-- gh-comment-id:2408172160 --> @PawelPotempa commented on GitHub (Oct 11, 2024): Got it, thanks for the clarification! However, this raises a question regarding user experience. If I understand the `user.setPassword` method correctly, it only makes sense to use it when the user is already signed in. Wouldn’t it make sense to also allow the user to create a credential account via the password reset flow, if they initially signed up using a social login? If no user with the email exists, it would continue to ignore the reset attempt, as it currently does. Right now, if a user inputs their social account email in the password reset form, the email with the reset link is sent, the user can visit the link and attempt to reset the password, however, the reset attempt fails because no credential account exists. It might feel more intuitive if this process allowed the user to set up a password, creating a credential account in the process. I believe some platforms (e.g., Spotify) use a similar flow, though I haven't checked recently.
Author
Owner

@Bekacru commented on GitHub (Oct 11, 2024):

Yes, the password reset flow should allow account creation. This is a bug and it should be fixed in the next release.

<!-- gh-comment-id:2408181671 --> @Bekacru commented on GitHub (Oct 11, 2024): Yes, the password reset flow should allow account creation. This is a bug and it should be fixed in the next release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16778