From e0e850b4c782d5b6f3a5c67fcffb7313c516168a Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang <153157069+AdisakKanthawilang@users.noreply.github.com> Date: Tue, 7 Oct 2025 17:18:54 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B9=80?= =?UTF-8?q?=E0=B8=87=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=99=E0=B9=84=E0=B8=82?= =?UTF-8?q?=20admin=20=E0=B9=83=E0=B8=AB=E0=B9=89=E0=B9=80=E0=B8=AB?= =?UTF-8?q?=E0=B9=87=E0=B8=99=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9?= =?UTF-8?q?=E0=B8=A5=E0=B8=97=E0=B8=B1=E0=B9=89=E0=B8=87=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B8=87=E0=B8=81=E0=B8=B1=E0=B8=94=20(#186)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/UserController.ts | 46 ++----------------------------- 1 file changed, 3 insertions(+), 43 deletions(-) diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index 38daaeae..4f90afeb 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -499,49 +499,9 @@ export class KeycloakController extends Controller { }, }, }); - - if ( - profile?.current_holders[0]?.orgRootId && - profile?.current_holders[0]?.orgChild1Id == null - ) { - checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}' - and current_holders.orgChild1Id IS NULL - and current_holders.orgChild2Id IS NULL - and current_holders.orgChild3Id IS NULL - and current_holders.orgChild4Id IS NULL`; - } else if ( - profile?.current_holders[0]?.orgChild1Id && - profile?.current_holders[0]?.orgChild2Id == null - ) { - checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}' - and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}' - and current_holders.orgChild2Id IS NULL - and current_holders.orgChild3Id IS NULL - and current_holders.orgChild4Id IS NULL`; - } else if ( - profile?.current_holders[0]?.orgChild2Id && - profile?.current_holders[0]?.orgChild3Id == null - ) { - checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}' - and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}' - and current_holders.orgChild2Id = '${profile?.current_holders[0]?.orgChild2Id}' - and current_holders.orgChild3Id IS NULL - and current_holders.orgChild4Id IS NULL`; - } else if ( - profile?.current_holders[0]?.orgChild3Id && - profile?.current_holders[0]?.orgChild4Id == null - ) { - checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}' - and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}' - and current_holders.orgChild2Id = '${profile?.current_holders[0]?.orgChild2Id}' - and current_holders.orgChild3Id = '${profile?.current_holders[0]?.orgChild3Id}' - and current_holders.orgChild4Id IS NULL`; - } else if (profile?.current_holders[0]?.orgChild4Id) { - checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}' - and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}' - and current_holders.orgChild2Id = '${profile?.current_holders[0]?.orgChild2Id}' - and current_holders.orgChild3Id = '${profile?.current_holders[0]?.orgChild3Id}' - and current_holders.orgChild4Id = '${profile?.current_holders[0]?.orgChild4Id}'`; + //ADMIN เห็นทั้งหน่วยงานที่สังกัด + if (profile?.current_holders[0]?.orgRootId) { + checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'`; } }