File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -570,13 +570,18 @@ def update_user_role(instance, user):
570570 # 需要判断当前角色的权限 不能删除系统管理员 空间管理员 普通管理员等角色
571571 # role_setting是一个数组 结构式 [{role_id:1,workspace_ids:[1,2]}]
572572 # 如果role_id不包含ADMIN 就直接报错 如果WORKSPACE_MANAGE 或者USER 必须判断workspace_ids是否包含默认工作空间 不包含就报错
573- admin_role_id = RoleConstants .ADMIN .value
573+ admin_role_id = RoleConstants .ADMIN .name
574+ workspace_manage_role_id = RoleConstants .WORKSPACE_MANAGE .name
575+ # 判断内置的三个角色是不是不在
576+ current_role_ids = {item ['role_id' ] for item in role_setting }
577+ initial_role = [admin_role_id , workspace_manage_role_id , RoleConstants .USER .name ]
578+ if not set (initial_role ).issubset (current_role_ids ):
579+ raise AppApiException (1004 , _ ("Cannot delete built-in role" ))
574580
575581 if not any (item ['role_id' ] == str (admin_role_id ) for item in role_setting ):
576582 raise AppApiException (1004 , _ ("Cannot delete built-in role" ))
577583
578584 # 验证 WORKSPACE_MANAGE 或 USER 是否包含默认工作空间
579- workspace_manage_role_id = RoleConstants .WORKSPACE_MANAGE .value
580585 default_workspace_id = 'default'
581586
582587 for item in role_setting :
You can’t perform that action at this time.
0 commit comments