Skip to content

Commit 9728407

Browse files
committed
perf: 允许管理员更新用户角色不受限制
1 parent 27bb328 commit 9728407

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fastapi_user_auth/admin/actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ async def handle(self, request: Request, item_id: List[str], data: schema, **kwa
160160
return BaseApiOut(status=0, msg="不能修改自己的权限")
161161
enforcer: AsyncEnforcer = self.site.auth.enforcer
162162
role_keys = [f"r:{role}" for role in data.role_keys.split(",") if role]
163-
if role_keys and identity != SystemUserEnum.ROOT:
163+
if role_keys and identity not in [SystemUserEnum.ROOT, SystemUserEnum.ADMIN]:
164164
# 检查当前用户是否有对应的角色,只有自己拥有的角色才能分配给其他主体
165165
user_role_keys = await self.site.auth.enforcer.get_implicit_roles_for_user("u:" + identity)
166166
role_keys = [role for role in role_keys if role in user_role_keys] # 过滤掉当前用户的角色

0 commit comments

Comments
 (0)