role api issue

This commit is contained in:
Gowtham M 2026-07-17 13:59:31 +05:30
parent 3590fbb39f
commit 6ba17a3a6f
2 changed files with 6 additions and 2 deletions

View File

@ -2034,6 +2034,9 @@ paths:
put:
tags: [Roles]
summary: Save permission matrix for role
description: >
Grants only actions that exist for each module. Sparse modules (e.g. SETTINGS view/edit,
REPORTS/AUDIT_LOGS view/export) ignore true flags for actions that have no permission row.
requestBody:
required: true
content:

View File

@ -406,8 +406,9 @@ const savePermissionMatrix = async (id, matrix, userId, requestId) => {
const perm = catalog.find(
(p) => p.module_id.toString() === String(row.module_id) && p.action === action
);
if (!perm)
throw new ApiError(422, `Permission not found for module ${row.module_id}:${action}`);
// Sparse modules (e.g. SETTINGS view/edit only, REPORTS view/export) have no row for
// every action — ignore grants for actions that do not exist in the catalog.
if (!perm) continue;
permissionIds.push(perm.id);
}
}