updatePassword()
Updates the password for one user through the backend management API.
Usage
The following example shows a basic usage of the backend client from @wacht/nextjs/server.
import { wachtClient } from '@wacht/nextjs/server';export async function updatePassword(userId: string, newPassword: string) { const client = await wachtClient(); await client.users.updatePassword(userId, { new_password: newPassword, });}Signature
function updatePassword( userId: string, request: UpdatePasswordRequest,): Promise<void>Parameters
›userId?: string | undefined;
userId?: string | undefined;Stable id of the user whose password should be changed.
›request?: UpdatePasswordRequest | undefined;
request?: UpdatePasswordRequest | undefined;Password update payload.
›new_password?: string | undefined;
new_password?: string | undefined;New password to set for the user.
›skip_password_check?: boolean | undefined;
skip_password_check?: boolean | undefined;When `true`, bypasses the normal password validation check.
What it does
This is the direct administrative password-change operation for an existing user.
It updates the stored password and does not return a user object on success.
Validation
The backend validates the new password against the deployment password rules unless you explicitly pass
skip_password_check: true.Use the skip flag carefully. It is an override for administrative flows, not the normal default.
Return value
This method resolves with no value when the password update succeeds.
Examples
Set a new password
import { wachtClient } from '@wacht/nextjs/server';export async function resetPassword(userId: string, newPassword: string) { const client = await wachtClient(); await client.users.updatePassword(userId, { new_password: newPassword, });}Skip password checks during an import or recovery flow
import { wachtClient } from '@wacht/nextjs/server';export async function importPassword(userId: string, password: string) { const client = await wachtClient(); await client.users.updatePassword(userId, { new_password: password, skip_password_check: true, });}