From 807242dd7816d5af9fd892c19b55159972703d99 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 May 2026 11:35:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=97=A0=E8=BF=94=E5=9B=9E=E5=80=BCbug=20+=20setup=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/web_api.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/web_api.py b/core/web_api.py index 116338b..3a28025 100644 --- a/core/web_api.py +++ b/core/web_api.py @@ -226,7 +226,7 @@ def setup_page(): g_db = get_global_db() if g_db: has_users = g_db.get_web_users_count() > 0 - elif graph_db: + elif graph_db and graph_db is not g_db: has_users = graph_db.get_web_users_count() > 0 if has_users: return redirect('/login') @@ -265,6 +265,9 @@ def api_login(): return jsonify({"success": True}) + # 登录失败 + return jsonify({"success": False, "error": "用户名或密码错误"}) + @app.route('/api/logout', methods=['POST']) def api_logout(): """登出接口""" @@ -356,6 +359,11 @@ def api_setup(): """首次设置 - 创建初始管理员用户""" # 只有没有任何用户时才允许设置 g_db = get_global_db() + # Log the count for debugging + if g_db: + import logging + count = g_db.get_web_users_count() + logging.warning(f"[api_setup] web_users count: {count}") if g_db and g_db.get_web_users_count() > 0: return jsonify({"success": False, "error": "用户已存在,不允许重复设置"}), 400