feat(middlewares): add access to admin services for super-admin

This commit is contained in:
OxSaitama 2023-07-24 13:59:47 +02:00
parent 2f5720f2b3
commit ad4b43e56e

View File

@ -9,13 +9,13 @@ export default async function ruleHandler(req: Request, response: Response, next
response.status(HttpCodes.UNAUTHORIZED).send("Missing rules in JWT");
return;
}
// const namespace = req.path && req.path.split("/")[3];
// const role = req.body.user.role;
const namespace = req.path && req.path.split("/")[3];
const role = req.body.user.role;
// if (namespace != "notary" && role != namespace) {
// response.status(HttpCodes.UNAUTHORIZED).send("Unauthorized with this role");
// return;
// }
if (namespace != "notary" && role != namespace && role != "super-admin") {
response.status(HttpCodes.UNAUTHORIZED).send("Unauthorized with this role");
return;
}
if (!rules.includes(req.method + " " + service)) {
response.status(HttpCodes.UNAUTHORIZED).send("Unauthorized with those rules");