feat(role): 根据role判断用户的权限

This commit is contained in:
sophie committed 2026-09-18 09:21:04 +08:00
1 parent 80d78130f8
commit a24bd94d43
93 files changed
+4472 -387

No files matched your search

@@ -91,7 +91,7 @@ def supports(*, user, agent, query: str) -> bool:
普通知识问答、普通员工提问或其他 Agent 一律不命中。
Args:
user: 当前聊天用户代理对象;需至少包含 role。
user: 当前聊天用户;须能 has_feature_permission('training_hr_manage')。
agent: 当前 Agent 代理对象;需能识别是否为员工培训 Agent。
query: 用户原始问题。
@@ -100,7 +100,7 @@ def supports(*, user, agent, query: str) -> bool:
"""
if not is_training_chat_agent(agent):
return False
if str(getattr(user, 'role', '') or '').strip() not in {'admin', 'hr'}:
if not bool(getattr(user, 'has_feature_permission', None) and user.has_feature_permission('training_hr_manage')):
return False
return (
_matches_any(query, _TRAINING_TOTAL_PATTERNS)