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}'`; } }