[GH-ISSUE #3553] Create an account on setUserPassword if account does not exist #18274

Closed
opened 2026-04-15 16:41:48 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @jpainam on GitHub (Jul 23, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3553

Hi, I’m migrating users to better-auth and want them to reset their passwords. However, auth.api.setUserPassword fails if the user doesn’t already have a credential account in the Account table.

New users work fine with signUp since it creates both the user and the account.

Can setUserPassword fallback to creating a credential account if one doesn’t exist?

Originally created by @jpainam on GitHub (Jul 23, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3553 Hi, I’m migrating users to better-auth and want them to reset their passwords. However, `auth.api.setUserPassword` fails if the user doesn’t already have a `credential` account in the `Account` table. New users work fine with `signUp` since it creates both the user and the account. Can setUserPassword fallback to creating a credential account if one doesn’t exist?
GiteaMirror added the lockedenhancement labels 2026-04-15 16:41:48 -05:00
Author
Owner

@Kinfe123 commented on GitHub (Aug 11, 2025):

hmm..i guess you should make a fallback to that if you want to make sure to migration work. but i dont think this could be a right fit to have a fallback to on the core api.

<!-- gh-comment-id:3175428679 --> @Kinfe123 commented on GitHub (Aug 11, 2025): hmm..i guess you should make a fallback to that if you want to make sure to migration work. but i dont think this could be a right fit to have a fallback to on the core api.
Author
Owner

@neacsugeorge commented on GitHub (Sep 16, 2025):

Hello @Kinfe123 ,

Are there any plans to support this in the future? As an admin user, I am unable to set a user's password if they don't have a credential account. We're currently creating the credential account manually using the ORM and then calling setUserPassword. What would be the expected flow for achieving this with the current better-auth API?

Thank you.

<!-- gh-comment-id:3298044570 --> @neacsugeorge commented on GitHub (Sep 16, 2025): Hello @Kinfe123 , Are there any plans to support this in the future? As an admin user, I am unable to set a user's password if they don't have a credential account. We're currently creating the credential account manually using the ORM and then calling setUserPassword. What would be the expected flow for achieving this with the current better-auth API? Thank you.
Author
Owner

@jpainam commented on GitHub (Sep 16, 2025):

Hello @Kinfe123 ,

Are there any plans to support this in the future? As an admin user, I am unable to set a user's password if they don't have a credential account. We're currently creating the credential account manually using the ORM and then calling setUserPassword. What would be the expected flow for achieving this with the current better-auth API?

Thank you.

This is what I ended up doing. Manually inserting the credentials if the user doesn’t have an account yet. And set a password. It also doesn’t allow you to send password reset or password forgot if the user has no credentials.

<!-- gh-comment-id:3299303148 --> @jpainam commented on GitHub (Sep 16, 2025): > Hello [@Kinfe123](https://github.com/Kinfe123) , > > Are there any plans to support this in the future? As an admin user, I am unable to set a user's password if they don't have a credential account. We're currently creating the credential account manually using the ORM and then calling setUserPassword. What would be the expected flow for achieving this with the current better-auth API? > > Thank you. This is what I ended up doing. Manually inserting the credentials if the user doesn’t have an account yet. And set a password. It also doesn’t allow you to send password reset or password forgot if the user has no credentials.
Author
Owner

@mjpowersjr commented on GitHub (Oct 29, 2025):

I hit this issue as well. In my case, the user registered via magic link, which did not insert a record into the account table, only the user table.

<!-- gh-comment-id:3462400849 --> @mjpowersjr commented on GitHub (Oct 29, 2025): I hit this issue as well. In my case, the user registered via magic link, which did not insert a record into the account table, only the user table.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18274