Allow an admin to set a user password #1850

Closed
opened 2026-03-13 09:08:02 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @maelp on GitHub (Sep 5, 2025).

Is this suited for github?

  • Yes, this is suited for github

Right now, auth.api.setPassword requires the current user session to be given, in order to allow the user to change his password.

But there are cases (like seeding user in test database, or providing an ad-hoc mechanism to set initial passwords by the admin) where we would want to have a setPassword({userId, newPassword}) (only accessible in the backend)

Describe the solution you'd like

Allow setPassword to be called with a userId as parameter (and not using the user in the current session — which might not exist when running from an automated script)

Describe alternatives you've considered

Re-implement the creation of the corresponding account, but this is error-prone

Additional context

No response

Originally created by @maelp on GitHub (Sep 5, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Right now, `auth.api.setPassword` requires the current user session to be given, in order to allow the user to change his password. But there are cases (like seeding user in test database, or providing an ad-hoc mechanism to set initial passwords by the admin) where we would want to have a `setPassword({userId, newPassword})` (only accessible in the backend) ### Describe the solution you'd like Allow setPassword to be called with a `userId` as parameter (and not using the user in the current session — which might not exist when running from an automated script) ### Describe alternatives you've considered Re-implement the creation of the corresponding account, but this is error-prone ### Additional context _No response_
GiteaMirror added the enhancement label 2026-03-13 09:08:02 -05:00
Author
Owner

@ping-maxwell commented on GitHub (Oct 6, 2025):

we have auth.api.setUserPassword which does this

@ping-maxwell commented on GitHub (Oct 6, 2025): we have auth.api.setUserPassword which does this
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1850