เพิ่ม role=> description

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-05-31 11:53:26 +07:00
parent 77c7574809
commit ecaab4fc5c

View file

@ -151,21 +151,18 @@ export async function getUserList(first = "", max = "", search = "") {
} }
export async function getUserCount() { export async function getUserCount() {
const res = await fetch( const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/users/count`, {
`${KC_URL}/admin/realms/${KC_REALM}/users/count`, headers: {
{ authorization: `Bearer ${await getToken()}`,
headers: {
"authorization": `Bearer ${await getToken()}`,
"content-type": `application/json`, "content-type": `application/json`,
}, },
}, }).catch((e) => console.log("Keycloak Error: ", e));
).catch((e) => console.log("Keycloak Error: ", e));
if (!res) return false; if (!res) return false;
if (!res.ok) { if (!res.ok) {
return Boolean(console.error("Keycloak Error Response: ", await res.json())); return Boolean(console.error("Keycloak Error Response: ", await res.json()));
} }
return await res.json(); return await res.json();
} }
@ -283,13 +280,17 @@ export async function getRoles(name?: string) {
const data = (await res.json()) as any; const data = (await res.json()) as any;
if (Array.isArray(data)) { if (Array.isArray(data)) {
return data.map((v: Record<string, string>) => ({ id: v.id, name: v.name })); return data.map((v: Record<string, string>) => ({
id: v.id,
name: v.name,
description: v.description,
}));
} }
return { // return {
id: data.id, // id: data.id,
name: data.name, // name: data.name,
}; // };
} }
/** /**