refactor: user relation

This commit is contained in:
Methapon2001 2024-07-01 13:24:02 +07:00
parent a74d8b63b1
commit 2bd30b735d
21 changed files with 607 additions and 185 deletions

View file

@ -4,7 +4,7 @@ import {
createUser,
deleteUser,
editUser,
getRoles,
listRole,
removeUserRoles,
} from "../services/keycloak";
@ -38,7 +38,7 @@ export class KeycloakController extends Controller {
@Get("role")
async getRole() {
const role = await getRoles();
const role = await listRole();
if (Array.isArray(role))
return role.filter(
(a) =>
@ -49,7 +49,7 @@ export class KeycloakController extends Controller {
@Post("{userId}/role")
async addRole(@Path() userId: string, @Body() body: { role: string[] }) {
const list = await getRoles();
const list = await listRole();
if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server.");
@ -63,7 +63,7 @@ export class KeycloakController extends Controller {
@Delete("{userId}/role/{roleId}")
async deleteRole(@Path() userId: string, @Path() roleId: string) {
const list = await getRoles();
const list = await listRole();
if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server.");