mirror of
https://gitcode.com/JianFeeeee/TrulyMEM-TrueHumanMEM.git
synced 2026-09-21 17:38:18 +00:00
fix: 修复登录无返回值bug + setup判断逻辑
This commit is contained in:
@ -226,7 +226,7 @@ def setup_page():
|
|||||||
g_db = get_global_db()
|
g_db = get_global_db()
|
||||||
if g_db:
|
if g_db:
|
||||||
has_users = g_db.get_web_users_count() > 0
|
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
|
has_users = graph_db.get_web_users_count() > 0
|
||||||
if has_users:
|
if has_users:
|
||||||
return redirect('/login')
|
return redirect('/login')
|
||||||
@ -265,6 +265,9 @@ def api_login():
|
|||||||
|
|
||||||
return jsonify({"success": True})
|
return jsonify({"success": True})
|
||||||
|
|
||||||
|
# 登录失败
|
||||||
|
return jsonify({"success": False, "error": "用户名或密码错误"})
|
||||||
|
|
||||||
@app.route('/api/logout', methods=['POST'])
|
@app.route('/api/logout', methods=['POST'])
|
||||||
def api_logout():
|
def api_logout():
|
||||||
"""登出接口"""
|
"""登出接口"""
|
||||||
@ -356,6 +359,11 @@ def api_setup():
|
|||||||
"""首次设置 - 创建初始管理员用户"""
|
"""首次设置 - 创建初始管理员用户"""
|
||||||
# 只有没有任何用户时才允许设置
|
# 只有没有任何用户时才允许设置
|
||||||
g_db = get_global_db()
|
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:
|
if g_db and g_db.get_web_users_count() > 0:
|
||||||
return jsonify({"success": False, "error": "用户已存在,不允许重复设置"}), 400
|
return jsonify({"success": False, "error": "用户已存在,不允许重复设置"}), 400
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user