check workflow

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2024-10-22 08:21:29 +07:00
parent 358a17e40d
commit 168cfcee46
9 changed files with 1667 additions and 1836 deletions

View file

@ -46,16 +46,6 @@ class CheckAuth {
.GetData(req, `/org/permission/org/${system}/${action}`)
.then(async 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],
@ -132,16 +122,6 @@ class CheckAuth {
.GetData(req, `/org/permission/user/${system}/${action}/${profileId}`)
.then(async x => {
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) if (x.orgChild1Id != org.child1[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"
@ -159,6 +139,22 @@ class CheckAuth {
}
})
}
public async Workflow(req: RequestWithUser, id: string, sysName: string) {
if (req.headers.hasOwnProperty("api_key") && req.headers["api_key"] && req.headers["api_key"] == process.env.API_KEY) {
return null
}
return await new CallAPI()
.PostData(req, "/org/workflow/keycloak/isofficer", {
refId: id,
sysName: sysName,
})
.then(x => {
return true
})
.catch(x => {
return false
})
}
public async PermissionCreate(req: RequestWithUser, system: string) {
return await this.Permission(req, system, "CREATE")
}