From bf0dfaf2e60c499381e23738107eabc6892ac35f Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 18 Jul 2023 14:11:30 +0200 Subject: [PATCH] :bug: Fixing crash when no rules in JWT --- src/app/middlewares/RulesHandler.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/middlewares/RulesHandler.ts b/src/app/middlewares/RulesHandler.ts index bf24fc55..33bd1c07 100644 --- a/src/app/middlewares/RulesHandler.ts +++ b/src/app/middlewares/RulesHandler.ts @@ -4,6 +4,11 @@ import { NextFunction, Request, Response } from "express"; export default async function ruleHandler(req: Request, response: Response, next: NextFunction) { const rules = req.body.user.rules; const service = req.path && req.path.split("/")[4]; + + if(!rules){ + response.status(HttpCodes.UNAUTHORIZED).send("Missing rules in JWT"); + return; + } // const namespace = req.path && req.path.split("/")[3]; // const role = req.body.user.role;