add createNewt action and remove max orgs restriction

This commit is contained in:
miloschwartz 2025-03-26 22:20:22 -04:00
parent fefb07e14c
commit 5e2f9e1eeb
No known key found for this signature in database
4 changed files with 24 additions and 4 deletions

View file

@ -44,6 +44,8 @@ export async function verifyRoleAccess(
);
}
const orgIds = new Set(rolesData.map((role) => role.orgId));
// Check user access to each role's organization
for (const role of rolesData) {
const userOrgRole = await db
@ -69,7 +71,16 @@ export async function verifyRoleAccess(
req.userOrgId = role.orgId;
}
const orgId = req.userOrgId;
if (orgIds.size > 1) {
return next(
createHttpError(
HttpCode.FORBIDDEN,
"Roles must belong to the same organization"
)
);
}
const orgId = orgIds.values().next().value;
if (!orgId) {
return next(
@ -105,3 +116,4 @@ export async function verifyRoleAccess(
);
}
}