Skip to content

Commit

Permalink
fix: duplication bug
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 14, 2024
1 parent a4c5375 commit f36ab11
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions apps/api/src/lib/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export function hasPermission(
requireAll: boolean = true
): boolean {
// Admins have all permissions
if (user?.isAdmin) {
return true;
}
if (user?.isAdmin) {
return true;
}

// Convert single permission to array for consistent handling
const permissions = Array.isArray(requiredPermissions)
Expand Down Expand Up @@ -93,15 +93,16 @@ export function requirePermission(

if (!hasPermission(userWithRoles, requiredPermissions, requireAll)) {
return res.status(401).send({
message: "You do not have the required permission to access this resource.",
message:
"You do not have the required permission to access this resource.",
success: false,
status: 403,
});
}

next();
return;
} else {
next();
return;
}
} catch (error) {
next(error);
Expand Down

0 comments on commit f36ab11

Please sign in to comment.