diff --git a/src/middleware/role-checker.ts b/src/middleware/role-checker.ts index 5f46578..50ab1fd 100644 --- a/src/middleware/role-checker.ts +++ b/src/middleware/role-checker.ts @@ -14,7 +14,7 @@ export default function RoleChecker( if (jwt == undefined) { if (weakVerification) { - next(); + return next(); } return res.status(StatusCodes.BAD_REQUEST).json({ error: "NoJWT" }); @@ -33,22 +33,22 @@ export default function RoleChecker( const userRoles = payload.roles; if (weakVerification) { - next(); + return next(); } if (requiredRoles.length == 0) { - next(); + return next(); } // Admins (staff) can access any endpoint if (userRoles.includes(Role.Enum.ADMIN)) { - next(); + return next(); } // Corporate role can access corporate only endpoints if (requiredRoles.includes(Role.Enum.CORPORATE)) { if (userRoles.includes(Role.Enum.CORPORATE)) { - next(); + return next(); } }