Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix add users when there is more than 1 workspace #392

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions src/spaceone/identity/service/workspace_group_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,30 +532,24 @@ def add_users_to_workspace_group(
unique_user_ids = set()

def add_user(user_info, workspace_group_workspace_id=None):
if user_info["user_id"] not in unique_user_ids:
role_type = new_users_role_map[user_info["role_id"]]
user_data = {
"user_id": user_info["user_id"],
"role_id": user_info["role_id"],
"role_type": role_type,
role_type = new_users_role_map[user_info["role_id"]]
user_data = {
"user_id": user_info["user_id"],
"role_id": user_info["role_id"],
"role_type": role_type,
}

if workspace_group_workspace_id:
role_binding_params = {
**user_data,
"resource_group": "WORKSPACE",
"domain_id": domain_id,
"workspace_group_id": workspace_group_id,
"workspace_id": workspace_group_workspace_id,
}
self.rb_svc.create_role_binding(role_binding_params)

if workspace_group_workspace_id:
role_binding_params = {
**user_data,
"resource_group": "WORKSPACE",
"domain_id": domain_id,
"workspace_group_id": workspace_group_id,
"workspace_id": workspace_group_workspace_id,
}
new_user_rb_vo = self.rb_svc.create_role_binding(
role_binding_params
)
user_data = {
"user_id": new_user_rb_vo.user_id,
"role_id": new_user_rb_vo.role_id,
"role_type": new_user_rb_vo.role_type,
}
if user_info["user_id"] not in unique_user_ids:
workspace_group_new_users_info_list.append(user_data)
unique_user_ids.add(user_data["user_id"])

Expand Down
Loading