From f36ab11132de548671d5e865519d491e626f6162 Mon Sep 17 00:00:00 2001 From: Jack Andrews Date: Thu, 14 Nov 2024 13:35:05 +0000 Subject: [PATCH] fix: duplication bug --- apps/api/src/lib/roles.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/api/src/lib/roles.ts b/apps/api/src/lib/roles.ts index f68e68c10..03705b256 100644 --- a/apps/api/src/lib/roles.ts +++ b/apps/api/src/lib/roles.ts @@ -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) @@ -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);