This commit is contained in:
Bright 2024-05-30 17:13:48 +07:00
parent 7fdd950c85
commit ef4d34d333
2 changed files with 40 additions and 2 deletions

View file

@ -141,7 +141,7 @@ export async function getUserList(first = "", max = "", search = "") {
return Boolean(console.error("Keycloak Error Response: ", await res.json()));
}
return ((await res.json()) as any[]).slice(0, 5000).map((v: Record<string, string>) => ({
return ((await res.json()) as any[]).map((v: Record<string, string>) => ({
id: v.id,
username: v.username,
firstName: v.firstName,
@ -150,6 +150,25 @@ export async function getUserList(first = "", max = "", search = "") {
}));
}
export async function getUserCount() {
const res = await fetch(
`${KC_URL}/admin/realms/${KC_REALM}/users/count`,
{
headers: {
"authorization": `Bearer ${await getToken()}`,
"content-type": `application/json`,
},
},
).catch((e) => console.log("Keycloak Error: ", e));
if (!res) return false;
if (!res.ok) {
return Boolean(console.error("Keycloak Error Response: ", await res.json()));
}
return await res.json();
}
/**
* Update keycloak user by uuid
*