From 5ed0066c0ff15da3e6f6b4e1686c8dfd9b08f994 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 6 Sep 2024 15:25:26 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20=E0=B8=AA?= =?UTF-8?q?=E0=B8=B4=E0=B8=97=E0=B8=98=E0=B8=B4=E0=B9=8C=E0=B9=83=E0=B8=AB?= =?UTF-8?q?=E0=B9=89=E0=B8=84=E0=B9=89=E0=B8=99=E0=B9=84=E0=B8=A7=E0=B8=82?= =?UTF-8?q?=E0=B8=B6=E0=B9=89=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interfaces/permission.ts | 52 ++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/src/interfaces/permission.ts b/src/interfaces/permission.ts index 2ea6b91..fb2d669 100644 --- a/src/interfaces/permission.ts +++ b/src/interfaces/permission.ts @@ -42,12 +42,30 @@ class CheckAuth { req.headers["api_key"] && req.headers["api_key"] == process.env.API_KEY ) { - return null; + return { + root: null, + child1: null, + child2: null, + child3: null, + child4: null, + }; } return await new CallAPI() - .GetData(req, `/org/permission/org/${action}/${system}`) + .GetData(req, `/org/permission/org/${system}/${action}`) .then(async (x) => { + console.log(x); let privilege = x.privilege; + // if (action.trim().toLocaleUpperCase() == "CREATE") + // privilege = await this.PermissionCreate(req, system); + // if (action.trim().toLocaleUpperCase() == "DELETE") + // privilege = await this.PermissionDelete(req, system); + // if (action.trim().toLocaleUpperCase() == "GET") + // privilege = await this.PermissionGet(req, system); + // if (action.trim().toLocaleUpperCase() == "LIST") + // privilege = await this.PermissionList(req, system); + // if (action.trim().toLocaleUpperCase() == "UPDATE") + // privilege = await this.PermissionUpdate(req, system); + let data: any = { root: [null], child1: [null], @@ -124,25 +142,19 @@ class CheckAuth { return true; } return await new CallAPI() - .GetData(req, `/org/permission/user/${profileId}`) + .GetData(req, `/org/permission/user/${system}/${action}/${profileId}`) .then(async (x) => { - let org = { - root: [null], - child1: [null], - child2: [null], - child3: [null], - child4: [null], - }; - if (action.trim().toLocaleUpperCase() == "CREATE") - org = await this.PermissionOrgCreate(req, system); - if (action.trim().toLocaleUpperCase() == "DELETE") - org = await this.PermissionOrgDelete(req, system); - if (action.trim().toLocaleUpperCase() == "GET") - org = await this.PermissionOrgGet(req, system); - if (action.trim().toLocaleUpperCase() == "LIST") - org = await this.PermissionOrgList(req, system); - if (action.trim().toLocaleUpperCase() == "UPDATE") - org = await this.PermissionOrgUpdate(req, system); + let org = x.org; + // if (action.trim().toLocaleUpperCase() == "CREATE") + // org = await this.PermissionOrgCreate(req, system); + // if (action.trim().toLocaleUpperCase() == "DELETE") + // org = await this.PermissionOrgDelete(req, system); + // if (action.trim().toLocaleUpperCase() == "GET") + // org = await this.PermissionOrgGet(req, system); + // if (action.trim().toLocaleUpperCase() == "LIST") + // org = await this.PermissionOrgList(req, system); + // if (action.trim().toLocaleUpperCase() == "UPDATE") + // org = await this.PermissionOrgUpdate(req, system); if (org.root != null) if (x.orgRootId != org.root[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"; if (org.child1 != null)