mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 12:03:17 +00:00
27 lines
569 B
TypeScript
27 lines
569 B
TypeScript
"use server";
|
|
|
|
import { listUsers, passwordReset } from "@/lib/zitadel";
|
|
|
|
type ResetPasswordCommand = {
|
|
loginName: string;
|
|
organization?: string;
|
|
};
|
|
|
|
export async function resetPassword(command: ResetPasswordCommand) {
|
|
const users = await listUsers({
|
|
userName: command.loginName,
|
|
organizationId: command.organization,
|
|
});
|
|
|
|
if (
|
|
!users.details ||
|
|
users.details.totalResult !== BigInt(1) ||
|
|
!users.result[0].userId
|
|
) {
|
|
throw Error("Could not find user");
|
|
}
|
|
const userId = users.result[0].userId;
|
|
|
|
return passwordReset(userId);
|
|
}
|