fix(rag-perm): file_list/file_serve 维护者也需要看文件列表和下载——maintain或search任一通过
This commit is contained in:
parent
c9a2f4d7e8
commit
fd2a52a1a5
@ -584,7 +584,10 @@ async def file_serve_handler(request, params_kw, *args, **kwargs):
|
||||
doc = recs[0]
|
||||
ok, kb, msg = await check_kb_perm(env, sor, doc.kb_id, 'search')
|
||||
if not ok:
|
||||
return json.dumps({"error": "kb_perm_denied", "message": msg}, ensure_ascii=False)
|
||||
# 维护者也需要下载文件(管理职责)
|
||||
ok2, _, _ = await check_kb_perm(env, sor, doc.kb_id, 'maintain')
|
||||
if not ok2:
|
||||
return json.dumps({"error": "kb_perm_denied", "message": msg}, ensure_ascii=False)
|
||||
fp = doc.file_path or ''
|
||||
if fp.startswith('/rags/'):
|
||||
parts = [p for p in fp.split('/') if p]
|
||||
|
||||
@ -14,8 +14,11 @@ from rag.init import check_kb_perm
|
||||
env = request._run_ns
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
_ok, _kb, _msg = await check_kb_perm(env, sor, kb_id, 'search')
|
||||
if not _ok:
|
||||
return {"widgettype": "Text", "options": {"text": "⛔ " + _msg, "cfontsize": 13, "color": "#f56c6c", "halign": "center", "marginTop": "40px"}}
|
||||
if not _ok:
|
||||
# 维护者也需要看到文件列表/下载文件(管理职责)
|
||||
_ok2, _kb, _msg2 = await check_kb_perm(env, sor, kb_id, 'maintain')
|
||||
if not _ok2:
|
||||
return {"widgettype": "Text", "options": {"text": "⛔ " + _msg, "cfontsize": 13, "color": "#f56c6c", "halign": "center", "marginTop": "40px"}}
|
||||
|
||||
rows = []
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user