Skip to content

Commit

Permalink
Merge pull request #2181 from auslin-aot/bugfix/FWF-3562-Fix-user-lis…
Browse files Browse the repository at this point in the history
…t-display-other-tenant-roles

🐛 FWF-3562: [BugFix] Fixed user list display other tenant roles
  • Loading branch information
arun-s-aot authored Aug 8, 2024
2 parents 799225c + 9225c89 commit 4e9989c
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@ def __init__(self):
self.client = KeycloakAdminAPIService()
self.user_service = UserService()

def __populate_user_groups(self, user_list: List) -> List:
@user_context
def __populate_user_groups(self, user_list: List, **kwargs) -> List:
"""Collect groups for a user list and populate the role attribute."""
for user in user_list:
user["role"] = (
user_groups = (
self.client.get_user_groups(user.get("id")) if user.get("id") else []
)
if current_app.config.get("MULTI_TENANCY_ENABLED"):
logged_user: UserContext = kwargs["user"]
user_groups = [
group
for group in user_groups
if group["name"].startswith(logged_user.tenant_key)
]
user["role"] = user_groups
return user_list

def __populate_user_roles(self, user_list: List) -> List:
Expand Down

0 comments on commit 4e9989c

Please sign in to comment.