From acd27bde67c5e37dc5eabbc1fcc17de5680888bb Mon Sep 17 00:00:00 2001 From: yml Date: Thu, 19 Nov 2026 16:03:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(login):=20=E7=A8=B3=E5=AE=9A=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=A4=B1=E8=B4=A5=E4=BA=8B=E4=BB=B6=E5=B9=82=E7=AD=89?= =?UTF-8?q?=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/backend/services/login_service.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/web/backend/services/login_service.py b/web/backend/services/login_service.py index 5ff88b8..e299857 100644 --- a/web/backend/services/login_service.py +++ b/web/backend/services/login_service.py @@ -138,9 +138,15 @@ def _mark_attempt_failed( 失败重试会新建记录或新 attempt,因此是新的一条 —— 这是对的,那是新的事实。 """ completed_at = datetime.now(UTC) + attempt_at = task.attempt_at or completed_at + attempt_utc = ( + attempt_at.replace(tzinfo=UTC) + if attempt_at.tzinfo is None + else attempt_at.astimezone(UTC) + ) task.attempt_status = status if status in {"failed", "error"} else "failed" task.attempt_message = message - task.attempt_at = completed_at + task.attempt_at = attempt_at account = task.account if not (account and account.cookie): # 账号还没有任何 CK 需要保护:保持旧的失败语义,便于复用记录与页面统计。 @@ -163,7 +169,7 @@ def _mark_attempt_failed( account_id=account.id, event_type=EVENT_LOGIN_FAILED, title=f"登录失败:{message}", - occurred_at=completed_at, + occurred_at=attempt_at, detail={ "message": message, "kind": kind, @@ -173,7 +179,9 @@ def _mark_attempt_failed( source="login", subject_type="login", subject_key=kind, - source_ref=f"login_task:{task.id}:failed:{int(completed_at.timestamp())}", + source_ref=( + f"login_task:{task.id}:failed:{attempt_utc.strftime('%Y%m%dT%H%M%S')}" + ), )