error permission

This commit is contained in:
kittapath 2024-08-20 13:55:59 +07:00
parent bd1f889fba
commit a2e3c79a7c

View file

@ -1,16 +1,3 @@
import {
Controller,
Request,
Get,
Post,
Put,
Delete,
Patch,
Route,
Security,
Tags,
Path,
} from "tsoa";
import axios from "axios";
import { RequestWithUser } from "../middlewares/user";
import CallAPI from "./call-api";
@ -42,7 +29,11 @@ class CheckAuth {
return role.attrPrivilege;
})
.catch((x) => {
throw new HttpError(HttpStatus.FORBIDDEN, x);
if (x.status != undefined) {
throw new HttpError(x.status, x.message);
} else {
throw new HttpError(HttpStatus.FORBIDDEN, x);
}
});
}
public async PermissionOrg(req: RequestWithUser, system: string, action: string) {
@ -123,7 +114,11 @@ class CheckAuth {
return data;
})
.catch((x) => {
throw new HttpError(HttpStatus.FORBIDDEN, x);
if (x.status != undefined) {
throw new HttpError(x.status, x.message);
} else {
throw new HttpError(HttpStatus.FORBIDDEN, x);
}
});
}
public async PermissionOrgByUser(
@ -174,8 +169,8 @@ class CheckAuth {
return true;
})
.catch((x) => {
if (x.status == 403) {
throw new HttpError(HttpStatus.FORBIDDEN, x.message);
if (x.status != undefined) {
throw new HttpError(x.status, x.message);
} else {
throw new HttpError(HttpStatus.FORBIDDEN, x);
}