no message
This commit is contained in:
parent
6c67e490ae
commit
c5e0fcc4f7
4 changed files with 54 additions and 1 deletions
|
|
@ -736,3 +736,28 @@ export async function removeUserGroup(userId: string, groupId: string) {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Function to change user password
|
||||
export async function changeUserPassword(userId: string, newPassword: string) {
|
||||
try {
|
||||
console.log(await getToken());
|
||||
const res = await fetch(`${KC_URL}/admin/realms/${KC_REALMS}/users/${userId}/reset-password`, {
|
||||
// prettier-ignore
|
||||
headers: {
|
||||
"authorization": `Bearer ${await getToken()}`,
|
||||
"content-type": `application/json`,
|
||||
},
|
||||
method: "PUT",
|
||||
body: JSON.stringify({
|
||||
type: "password",
|
||||
value: newPassword,
|
||||
temporary: false, // Set to true if the user must reset their password on next login
|
||||
}),
|
||||
}).catch((e) => console.log("Keycloak Error: ", e));
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("Error changing password:", error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue