修复系统设置保存500:鉴权不再依赖缺失的lib.hub;补全order_prices初始化。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -30,8 +30,6 @@ def _api_login_required(hub_token_write_allowed: bool = False):
|
||||
def decorator(f):
|
||||
@wraps(f)
|
||||
def wrapped(*args, **kwargs):
|
||||
from lib.hub.hub_auth import request_allowed as hub_request_allowed
|
||||
|
||||
logged_in = bool(session.get("logged_in"))
|
||||
auth_disabled = (os.getenv("APP_AUTH_DISABLED") or "").strip().lower() in (
|
||||
"1",
|
||||
@@ -43,7 +41,20 @@ def _api_login_required(hub_token_write_allowed: bool = False):
|
||||
bridge = (os.getenv("HUB_BRIDGE_TOKEN") or "").strip()
|
||||
if hub_hdr and bridge and hub_hdr == bridge and not hub_token_write_allowed:
|
||||
return jsonify({"ok": False, "msg": "Hub Token 不可修改实例设置"}), 403
|
||||
if hub_request_allowed(logged_in, auth_disabled):
|
||||
|
||||
# crypto_okx 可无 lib.hub;鉴权与中控 request_allowed 对齐
|
||||
allowed = bool(auth_disabled or logged_in)
|
||||
if not allowed and hub_hdr and bridge and hub_hdr == bridge:
|
||||
allowed = True
|
||||
if not allowed:
|
||||
try:
|
||||
from lib.hub.hub_auth import request_allowed as hub_request_allowed
|
||||
|
||||
allowed = bool(hub_request_allowed(logged_in, auth_disabled))
|
||||
except ImportError:
|
||||
allowed = False
|
||||
|
||||
if allowed:
|
||||
return f(*args, **kwargs)
|
||||
return jsonify({"ok": False, "msg": "未登录"}), 401
|
||||
|
||||
|
||||
Reference in New Issue
Block a user