Skip to content

Commit

Permalink
return next()
Browse files Browse the repository at this point in the history
  • Loading branch information
aletya committed Apr 23, 2024
1 parent e66a95c commit 357eb12
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/middleware/role-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
Expand All @@ -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();
}
}

Expand Down

0 comments on commit 357eb12

Please sign in to comment.