docs: add example how to update password on the server (#831)

* add(docs): demo code to set password on the server.

* fix(docs): update password

---------

Co-authored-by: Bereket Engida <bekacru@gmail.com>
This commit is contained in:
Maxwell
2025-02-14 16:04:02 +10:00
committed by GitHub
parent b3371272fc
commit c4f89adbcd

View File

@@ -223,6 +223,24 @@ const { data, error } = await authClient.resetPassword({
});
```
### Update password
<Callout type="warn">
This only works on server-side, and the following code may change over time.
</Callout>
To set a password, you must hash it first:
```ts
const ctx = await auth.$context;
const hash = await ctx.password.hash("your-new-password");
```
Then, to set the password:
```ts
await ctx.internalAdapter.updatePassword("userId", hash) //(you can also use your orm directly)
```
### Configuration
**Password**