fix: treat SuperAdmin role name case-insensitively in permission checks

The seeded role is SuperAdmin, but the middleware only matched superAdmin, so SuperAdmin could be denied documents and other new permissions.
This commit is contained in:
2026-08-15 03:27:21 +03:30
parent e1772a2559
commit 877dfa65d5
+2 -2
View File
@@ -14,8 +14,8 @@ const requirePermission = (requiredPermission) => {
return next(new AppError('FORBIDDEN')); return next(new AppError('FORBIDDEN'));
} }
// Check if user is superAdmin (by role name or system status) const roleName = String(role.name || '').toLowerCase();
if (role.name === 'superAdmin' || (role.isSystem && role.permissions.includes('*'))) { if (roleName === 'superadmin' || (role.isSystem && role.permissions.includes('*'))) {
return next(); return next();
} }