Skip to content

Commit 9cec8ce

Browse files
committed
fix: 修复权限选项过滤逻辑
1 parent c7a0d99 commit 9cec8ce

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fastapi_user_auth/admin/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ def filter_options(options: List[Dict[str, Any]], filter_func: Callable[[Dict[st
5252
"""过滤选项,包含子选项.如果选项的children为空,则删除该选项"""
5353
result = []
5454
for option in options:
55-
if not filter_func(option):
56-
continue
5755
option = copy(option) # 防止children被修改
56+
has_children = False
5857
if option.get("children"):
5958
option["children"] = filter_options(option["children"], filter_func)
59+
has_children = bool(option["children"])
60+
if not filter_func(option) and not has_children: # 没有父级权限,并且没有子级权限
61+
continue
6062
result.append(option)
6163
return result
6264

0 commit comments

Comments
 (0)