From cd849d23230c71befd4609035ce7758bd3e1b8bb Mon Sep 17 00:00:00 2001 From: liuwei Date: Tue, 10 Jun 2025 12:01:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E6=8E=A8=E9=80=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/dashboard/blueprints/auth.py | 2 ++ admin/dashboard/blueprints/message_push.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) 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