Skip to content

Commit

Permalink
Merge pull request #381 from yjinjo/master
Browse files Browse the repository at this point in the history
Modify code such that deleted original users when adding workspace to workspace group
  • Loading branch information
yjinjo authored Sep 30, 2024
2 parents 84a033a + d00d692 commit a999537
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/spaceone/identity/service/workspace_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@ def _add_workspace_to_group(
else:
is_updatable = False
else:
self._delete_role_bindings(workspace_id, domain_id)
workspace_group_dict = workspace_group_vo.to_dict()
users = workspace_group_dict.get("users", [])
user_ids = [user.get("user_id") for user in users]
self._delete_role_bindings(workspace_id, domain_id, user_ids=user_ids)
self._create_role_bindings(
workspace_group_vo.users,
workspace_id,
Expand Down Expand Up @@ -505,12 +508,17 @@ def _remove_workspace_from_group_with_workspace_vo(
)

def _delete_role_bindings(
self, workspace_id: str, domain_id: str, existing_workspace_group_id: str = None
self,
workspace_id: str,
domain_id: str,
existing_workspace_group_id: str = None,
user_ids: List[str] = None,
):
rb_vos = self.rb_mgr.filter_role_bindings(
workspace_id=workspace_id,
domain_id=domain_id,
workspace_group_id=existing_workspace_group_id,
user_id=user_ids,
)
for rb_vo in rb_vos:
self.rb_mgr.delete_role_binding_by_vo(rb_vo)
Expand Down

0 comments on commit a999537

Please sign in to comment.