Refactor: consolidate to use @login_required (#15652)

Refactor: consolidate to use @login_required
This commit is contained in:
Wang Qi
2026-06-05 11:35:00 +08:00
committed by GitHub
parent 9f3e289b78
commit 4cbe597d7e
8 changed files with 55 additions and 126 deletions

View File

@@ -15,7 +15,6 @@
#
import asyncio
import functools
import importlib.util
import inspect
import json
@@ -390,17 +389,6 @@ def _load_dataset_module(monkeypatch):
def _get_error_permission_result(message=""):
return _get_result(code=_RetCode.AUTHENTICATION_ERROR, message=message)
def _token_required(func):
@functools.wraps(func)
async def _async_wrapper(*args, **kwargs):
return await func(*args, **kwargs)
@functools.wraps(func)
def _sync_wrapper(*args, **kwargs):
return func(*args, **kwargs)
return _async_wrapper if asyncio.iscoroutinefunction(func) else _sync_wrapper
api_utils_mod.deep_merge = _deep_merge
api_utils_mod.get_error_argument_result = _get_error_argument_result
api_utils_mod.get_error_data_result = _get_error_data_result
@@ -408,7 +396,6 @@ def _load_dataset_module(monkeypatch):
api_utils_mod.get_parser_config = lambda _chunk_method, _unused: {"auto": True}
api_utils_mod.get_result = _get_result
api_utils_mod.remap_dictionary_keys = lambda data: data
api_utils_mod.token_required = _token_required
api_utils_mod.add_tenant_id_to_kwargs = lambda func: func
api_utils_mod.verify_embedding_availability = lambda _embd_id, _tenant_id: (True, None)
monkeypatch.setitem(sys.modules, "api.utils.api_utils", api_utils_mod)
@@ -854,4 +841,3 @@ def test_delete_index_wipe_flag_unit(monkeypatch):
assert res["code"] == module.RetCode.SUCCESS, res
assert len(deleted) == 1, f"default wipe must call docStore.delete once: {deleted}"
assert cleared_phase_markers == ["kb-1"], cleared_phase_markers