form submit, addhumanuser implementation

This commit is contained in:
Max Peintner
2023-04-26 16:04:56 +02:00
parent 2047e19ed9
commit 4950af7d9f
3 changed files with 140 additions and 9 deletions

View File

@@ -62,4 +62,29 @@ export function getPasswordComplexityPolicy(
.then((resp) => resp.policy);
}
export type AddHumanUserData = {
displayName: string;
email: string;
password: string;
};
export function addHumanUser(
server: ZitadelServer,
{ email, displayName, password }: AddHumanUserData
): Promise<string> {
const mgmt = getManagement(server);
return mgmt
.addHumanUser(
{
email: { email, isEmailVerified: false },
profile: { displayName },
initialPassword: password,
},
{ metadata: orgMetadata(process.env.ZITADEL_ORG_ID ?? "") }
)
.then((resp) => {
console.log("added user", resp.userId);
return resp.userId;
});
}
export { server };