diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index ab083d6a..7abe92b8 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -92,7 +92,7 @@ export class KeycloakController extends Controller { firstName?: string; lastName?: string; email?: string; - roles?: string[]; + roles: string[]; profileId?: string; }, ) { @@ -105,6 +105,12 @@ export class KeycloakController extends Controller { if (typeof userId !== "string") { throw new Error(userId.errorMessage); } + const list = await getRoles(); + if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server."); + const result = await addUserRoles( + userId, + list.filter((v) => body.roles.includes(v.id)), + ); const now = new Date().toISOString(); const folderData: any = {