Unify auth context → role permission config resolution into a single pure utility (#18927)
## Summary - Consolidates duplicated auth-context-to-role-ID resolution logic (previously in `PermissionsService.resolveRolePermissionConfigFromAuthContext` and `CommonBaseQueryRunnerService.getRoleIdOrThrow`) into a single pure utility function `resolveRolePermissionConfig` in the ORM layer - The utility is synchronous and operates on cached data (`userWorkspaceRoleMap`, `apiKeyRoleMap`) already loaded into the workspace context — no async calls, no service dependencies - Adds `apiKeyRoleMap` to `ORMWorkspaceContext` (it was already in the workspace cache, just not loaded into the ORM context) - Removes `PermissionsService` dependency from `NavigationMenuItemRecordIdentifierService` - Removes `UserRoleService` and `ApiKeyRoleService` injections from `CommonBaseQueryRunnerService` ## Test plan - [ ] Existing typecheck passes (`npx nx typecheck twenty-server`) - [ ] Verify record identifier resolution still works for navigation menu items (user, system, API key, and application auth contexts) - [ ] Verify GraphQL CRUD queries still enforce correct role-based permissions - [ ] Verify API key authenticated requests resolve permissions correctly Made with [Cursor](https://cursor.com)
This commit is contained in:
+4
@@ -93,6 +93,7 @@ export class GlobalWorkspaceOrmManager {
|
||||
rolesPermissions: permissionsPerRoleId,
|
||||
ORMEntityMetadatas: entityMetadatas,
|
||||
userWorkspaceRoleMap,
|
||||
apiKeyRoleMap,
|
||||
flatRowLevelPermissionPredicateMaps,
|
||||
flatRowLevelPermissionPredicateGroupMaps,
|
||||
} = await this.workspaceCacheService.getOrRecompute(workspaceId, [
|
||||
@@ -103,6 +104,7 @@ export class GlobalWorkspaceOrmManager {
|
||||
'rolesPermissions',
|
||||
'ORMEntityMetadatas',
|
||||
'userWorkspaceRoleMap',
|
||||
'apiKeyRoleMap',
|
||||
'flatRowLevelPermissionPredicateMaps',
|
||||
'flatRowLevelPermissionPredicateGroupMaps',
|
||||
]);
|
||||
@@ -122,6 +124,7 @@ export class GlobalWorkspaceOrmManager {
|
||||
permissionsPerRoleId,
|
||||
entityMetadatas,
|
||||
userWorkspaceRoleMap,
|
||||
apiKeyRoleMap,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -167,6 +170,7 @@ export class GlobalWorkspaceOrmManager {
|
||||
permissionsPerRoleId: {},
|
||||
entityMetadatas,
|
||||
userWorkspaceRoleMap: {},
|
||||
apiKeyRoleMap: {},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user