From a30b03fb93af2892be11fbf00c509e5ca864024c Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Sun, 30 Aug 2026 00:33:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(i18n):=20=E6=9C=AA=E7=99=BB=E5=BD=95=20401?= =?UTF-8?q?=20=E8=BF=94=E5=9B=9E=E5=8F=8C=E8=AF=AD=E6=96=87=E6=A1=88?= =?UTF-8?q?=E3=80=8C=E7=99=BB=E5=BD=95=E7=8A=B6=E6=80=81=E5=B7=B2=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=EF=BC=8C=E8=AF=B7=E9=87=8D=E6=96=B0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - auth_helpers.py / app_legacy.py 的 api_login_required 401 响应改用 tr('auth.session_expired') - 新增 i18n key:zh 登录状态已过期,请重新登录 / en Your login session has expired. Please log in again. --- modules/i18n_messages/api_auth.py | 4 ++++ server/app_legacy.py | 2 +- server/auth_helpers.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/i18n_messages/api_auth.py b/modules/i18n_messages/api_auth.py index c73c259a..3eef9728 100644 --- a/modules/i18n_messages/api_auth.py +++ b/modules/i18n_messages/api_auth.py @@ -37,6 +37,10 @@ MESSAGES = { "zh-CN": "未登录", "en-US": "Not logged in", }, + "auth.session_expired": { + "zh-CN": "登录状态已过期,请重新登录", + "en-US": "Your login session has expired. Please log in again.", + }, "auth.host_mode_tutorial_not_applicable": { "zh-CN": "宿主机模式无需设置新手教程状态", "en-US": "Tutorial status does not apply in host mode", diff --git a/server/app_legacy.py b/server/app_legacy.py index eb71229e..5ff5bdf1 100644 --- a/server/app_legacy.py +++ b/server/app_legacy.py @@ -821,7 +821,7 @@ def api_login_required(view_func): @wraps(view_func) def wrapped(*args, **kwargs): if not is_logged_in(): - return jsonify({"error": "Unauthorized"}), 401 + return jsonify({"error": tr("auth.session_expired")}), 401 return view_func(*args, **kwargs) return wrapped diff --git a/server/auth_helpers.py b/server/auth_helpers.py index acb5b5d7..2daddbf0 100644 --- a/server/auth_helpers.py +++ b/server/auth_helpers.py @@ -34,7 +34,7 @@ def api_login_required(view_func): @wraps(view_func) def wrapped(*args, **kwargs): if not is_logged_in(): - return jsonify({"error": "Unauthorized"}), 401 + return jsonify({"error": tr("auth.session_expired")}), 401 return view_func(*args, **kwargs) return wrapped