Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

refactor: update requirePermissions check to include current company

Brad Barbincc21f166dd01
diff --git a/apps/carbon/app/services/auth/auth.server.ts b/apps/carbon/app/services/auth/auth.server.ts
index 4ac12d9977..bd7baeb9d9 100644
--- a/apps/carbon/app/services/auth/auth.server.ts
+++ b/apps/carbon/app/services/auth/auth.server.ts
@@ -113,14 +113,20 @@ export async function requirePermissions(
myClaims.permissions[permission][
action as "view" | "create" | "update" | "delete"
];
- return permissionForCompany.includes(0); // TODO: check if the user has access to the company
+ return (
+ permissionForCompany.includes(0) || // 0 is the wildcard for all companies
+ permissionForCompany.includes(companyId)
+ );
} else if (Array.isArray(permission)) {
return permission.every((p) => {
const permissionForCompany =
myClaims.permissions[p][
action as "view" | "create" | "update" | "delete"
];
- return permissionForCompany.includes(0); // TODO: check if the user has access to the company
+ return (
+ permissionForCompany.includes(0) || // 0 is the wildcard for all companies
+ permissionForCompany.includes(companyId)
+ );
});
} else {
return false;