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:
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user