diff --git a/admin/dashboard/blueprints/auth.py b/admin/dashboard/blueprints/auth.py index a1dd9c2..4b62d1b 100644 --- a/admin/dashboard/blueprints/auth.py +++ b/admin/dashboard/blueprints/auth.py @@ -1,5 +1,6 @@ from flask import Blueprint, render_template, request, redirect, url_for, session, current_app from functools import wraps +from loguru import logger # 创建认证蓝图 auth_bp = Blueprint('auth', __name__) @@ -30,6 +31,7 @@ def login(): if username == server.username and password == server.password: session['logged_in'] = True session['username'] = username # 存储用户名到session + logger.debug(f"Login successful. Session after login: {dict(session)}") return redirect(url_for('main.index')) else: error = '用户名或密码错误' diff --git a/admin/dashboard/blueprints/message_push.py b/admin/dashboard/blueprints/message_push.py index b23ffa2..acc6b00 100644 --- a/admin/dashboard/blueprints/message_push.py +++ b/admin/dashboard/blueprints/message_push.py @@ -55,8 +55,9 @@ def api_create_task(): return jsonify({"success": False, "error": "无效的请求数据"}), 400 # 获取用户名 - logger.debug(f"session:{session}") + logger.debug(f"Session before getting username: {dict(session)}") username = session.get('username') + logger.debug(f"Username from session: {username}") if not username: return jsonify({"success": False, "error": "未登录或会话已过期"}), 401