From c26aad70bdb23b287805da019770e0adc7f3bc92 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 23 Jan 2025 09:52:48 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=B1=E0=B9=8A=E0=B8=A1=20role=20?= =?UTF-8?q?=E0=B9=80=E0=B8=94=E0=B8=B4=E0=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 32cc5881..61db3922 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -2589,7 +2589,13 @@ export class CommandController extends Controller { } //ถ้ามีอยู่แล้วให้ใช้อันเดิม else { - // const _roleKeycloaks = await getRoleMappings(checkUser[0].id); + const rolesData = await getRoleMappings(checkUser[0].id); + if(rolesData) { + const _roleKeycloak = await this.roleKeycloakRepo.find({ + where: { name: In(rolesData.map((x:any) => x.name)) } + }); + profile.roleKeycloaks = _roleKeycloak && _roleKeycloak.length > 0 ? _roleKeycloak : []; + } profile.keycloak = checkUser[0].id; } profile.amount = item.amount ?? _null; @@ -3942,6 +3948,13 @@ export class CommandController extends Controller { profile.keycloak = userKeycloakId && typeof userKeycloakId === "string" ? userKeycloakId : ""; } else { + const rolesData = await getRoleMappings(checkUser[0].id); + if(rolesData) { + const _roleKeycloak = await this.roleKeycloakRepo.find({ + where: { name: In(rolesData.map((x:any) => x.name)) } + }); + profile.roleKeycloaks = _roleKeycloak && _roleKeycloak.length > 0 ? _roleKeycloak : []; + } profile.keycloak = checkUser[0].id; } @@ -4339,6 +4352,13 @@ export class CommandController extends Controller { // End Create Keycloak } else { + const rolesData = await getRoleMappings(checkUser[0].id); + if(rolesData) { + const _roleKeycloak = await this.roleKeycloakRepo.find({ + where: { name: In(rolesData.map((x:any) => x.name)) } + }); + profile.roleKeycloaks = _roleKeycloak && _roleKeycloak.length > 0 ? _roleKeycloak : []; + } profile.keycloak = checkUser[0].id; }