Force change password of user through API without session #546

Closed
opened 2026-03-13 07:52:12 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @JE4GLE on GitHub (Jan 10, 2025).

Is this suited for github?

  • Yes, this is suited for github

Is your feature request related to a problem? Please describe.

I need to use a workaround to change the password of a user. I need to hash it myself and save it in the database.

const ctx = await auth.$context;
ctx.password.hash("password")

Describe the solution you'd like

auth.api.changePassword(userId, password)

Describe alternatives you've considered

I need to use a workaround to change the password of a user. I need to hash it myself and save it in the database.

const ctx = await auth.$context;
ctx.password.hash("password")

Additional context

Use case

Due to requirements of the project, the user receives a recovery code during sign up. They should store it securely. Only this code can be used to reset the password, if forgotten. I am now at the state, where I have verified the recovery code and need to change the password without the user needing to be logged in.

Originally created by @JE4GLE on GitHub (Jan 10, 2025). ### Is this suited for github? - [X] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. I need to use a workaround to change the password of a user. I need to hash it myself and save it in the database. ```javascript const ctx = await auth.$context; ctx.password.hash("password") ``` ### Describe the solution you'd like `auth.api.changePassword(userId, password)` ### Describe alternatives you've considered I need to use a workaround to change the password of a user. I need to hash it myself and save it in the database. ```javascript const ctx = await auth.$context; ctx.password.hash("password") ``` ### Additional context Use case > Due to requirements of the project, the user receives a recovery code during sign up. They should store it securely. Only this code can be used to reset the password, if forgotten. I am now at the state, where I have verified the recovery code and need to change the password without the user needing to be logged in.
Author
Owner

@dosubot[bot] commented on GitHub (Jun 11, 2025):

Hi, @JE4GLE. I'm Dosu, and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • Feature request to enable password changes via an API without a user session.
  • Current workaround involves manually hashing and saving passwords to the database.
  • Proposed solution: Implement auth.api.changePassword(userId, password) after verifying a recovery code.
  • No activity or comments have been made on this issue yet.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the better-auth repository by commenting here.
  • If there is no response, the issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Jun 11, 2025): Hi, @JE4GLE. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - Feature request to enable password changes via an API without a user session. - Current workaround involves manually hashing and saving passwords to the database. - Proposed solution: Implement `auth.api.changePassword(userId, password)` after verifying a recovery code. - No activity or comments have been made on this issue yet. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of the better-auth repository by commenting here. - If there is no response, the issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Author
Owner

@JE4GLE commented on GitHub (Jun 11, 2025):

Afaik, it is still relevant :)

@JE4GLE commented on GitHub (Jun 11, 2025): Afaik, it is still relevant :)
Author
Owner

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

This can be done via the admin plugin.

https://www.better-auth.com/docs/plugins/admin#set-user-password

@frectonz commented on GitHub (Aug 11, 2025): This can be done via the `admin` plugin. https://www.better-auth.com/docs/plugins/admin#set-user-password
Author
Owner

@sq-tupai commented on GitHub (Jan 6, 2026):

really bullshit design of server side sdk, idk why server side admin plugin still need headers to perform users password update.

@sq-tupai commented on GitHub (Jan 6, 2026): really bullshit design of server side sdk, idk why server side admin plugin still need headers to perform users password update.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#546