diff --git a/modules/interfaces/interfaceDbAppObjects.py b/modules/interfaces/interfaceDbAppObjects.py index 26ded39d..da8ec08f 100644 --- a/modules/interfaces/interfaceDbAppObjects.py +++ b/modules/interfaces/interfaceDbAppObjects.py @@ -304,17 +304,22 @@ class AppObjects: """ Returns users for a specific mandate if user has access. Supports optional pagination, sorting, and filtering. + For SYSADMIN, returns all users regardless of mandate. Args: - mandateId: The mandate ID to get users for + mandateId: The mandate ID to get users for (ignored for SYSADMIN) pagination: Optional pagination parameters. If None, returns all items. Returns: If pagination is None: List[User] If pagination is provided: PaginatedResult with items and metadata """ - # Get users for this mandate - users = self.db.getRecordset(UserInDB, recordFilter={"mandateId": mandateId}) + # For SYSADMIN, get all users regardless of mandate + # For others, filter by mandate + if self.currentUser and self.currentUser.privilege == UserPrivilege.SYSADMIN: + users = self.db.getRecordset(UserInDB) + else: + users = self.db.getRecordset(UserInDB, recordFilter={"mandateId": mandateId}) filteredUsers = self._uam(UserInDB, users) # If no pagination requested, return all items