service call service
This commit is contained in:
parent
1736f5043e
commit
927d9563f6
2 changed files with 14 additions and 5 deletions
|
|
@ -23,6 +23,7 @@ class CallAPI {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `${token}`,
|
Authorization: `${token}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
api_key: process.env.API_KEY,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return response.data.result;
|
return response.data.result;
|
||||||
|
|
@ -39,6 +40,7 @@ class CallAPI {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `${token}`,
|
Authorization: `${token}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
api_key: process.env.API_KEY,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return response.data.result;
|
return response.data.result;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,13 @@ import HttpStatus from "./http-status";
|
||||||
|
|
||||||
class CheckAuth {
|
class CheckAuth {
|
||||||
public async Permission(req: RequestWithUser, system: string, action: string) {
|
public async Permission(req: RequestWithUser, system: string, action: string) {
|
||||||
|
if (
|
||||||
|
req.headers.hasOwnProperty("api_key") &&
|
||||||
|
req.headers["api_key"] &&
|
||||||
|
req.headers["api_key"] == process.env.API_KEY
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.GetData(req, "/org/permission")
|
.GetData(req, "/org/permission")
|
||||||
.then((x) => {
|
.then((x) => {
|
||||||
|
|
@ -39,19 +46,19 @@ class CheckAuth {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public async PermissionCreate(req: RequestWithUser, system: string) {
|
public async PermissionCreate(req: RequestWithUser, system: string) {
|
||||||
this.Permission(req, system, "CREATE");
|
return await this.Permission(req, system, "CREATE");
|
||||||
}
|
}
|
||||||
public async PermissionDelete(req: RequestWithUser, system: string) {
|
public async PermissionDelete(req: RequestWithUser, system: string) {
|
||||||
this.Permission(req, system, "DELETE");
|
return await this.Permission(req, system, "DELETE");
|
||||||
}
|
}
|
||||||
public async PermissionGet(req: RequestWithUser, system: string) {
|
public async PermissionGet(req: RequestWithUser, system: string) {
|
||||||
this.Permission(req, system, "GET");
|
return await this.Permission(req, system, "GET");
|
||||||
}
|
}
|
||||||
public async PermissionList(req: RequestWithUser, system: string) {
|
public async PermissionList(req: RequestWithUser, system: string) {
|
||||||
this.Permission(req, system, "LIST");
|
return await this.Permission(req, system, "LIST");
|
||||||
}
|
}
|
||||||
public async PermissionUpdate(req: RequestWithUser, system: string) {
|
public async PermissionUpdate(req: RequestWithUser, system: string) {
|
||||||
this.Permission(req, system, "UPDATE");
|
return await this.Permission(req, system, "UPDATE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue