From 339b169f3c9f597eab962b2f10535f6c8448dd70 Mon Sep 17 00:00:00 2001 From: Nixevol Date: Tue, 10 Nov 2026 09:08:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=B7=E6=B1=A0=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=88=97=E5=8F=AF=E4=BB=A5=E9=87=8D=E6=96=B0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E8=BF=99=E4=B8=AA=E8=B4=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/http.py | 11 +++++++++++ backend/app/nqi/client.py | 1 + web/src/features/admin/PoolView.vue | 27 +++++++++++++++++++++++---- web/src/features/auth/LoginView.vue | 10 +++++----- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/backend/app/api/http.py b/backend/app/api/http.py index bd4e1c9..5329129 100644 --- a/backend/app/api/http.py +++ b/backend/app/api/http.py @@ -163,6 +163,9 @@ async def nqi_start(body: dict) -> dict: await purge() username = str(body.get("username") or "").strip() purpose = "pool" if body.get("purpose") == "pool" else "login" + lock_account = purpose == "pool" and bool(body.get("lockAccount")) + if lock_account and not username: + raise _bad("请选择要重新登录的账号") resume_cookies: list = [] resume_name = username with session_scope() as session: @@ -191,6 +194,8 @@ async def nqi_start(body: dict) -> dict: client = NqiClient() try: challenge = await client.open_login() + if lock_account: + challenge.expected_login = username except NqiError as exc: await client.aclose() raise _bad(str(exc)) from exc @@ -244,6 +249,8 @@ async def nqi_finish(body: dict) -> dict: sms_code = str(body.get("smsCode") or "").strip() if not username or not password or not captcha: raise _bad("请填写账号、密码和验证码") + if challenge.expected_login and username != challenge.expected_login: + raise _bad("请使用原来的账号重新登录") try: if not challenge.config_ready: code = await client.prepare_login(challenge, username, password, captcha) @@ -260,6 +267,10 @@ async def nqi_finish(body: dict) -> dict: pass return {**_captcha_body(session_id, challenge), "status": "need_captcha", "message": message} challenge.password = "" + if challenge.expected_login and str(user.get("loginId") or "").strip() != challenge.expected_login: + await client.aclose() + drop(session_id) + raise _bad("登录的不是这个账号") adhoc_ready = await client.renew_ticket() cookies = client.export_cookies() await client.aclose() diff --git a/backend/app/nqi/client.py b/backend/app/nqi/client.py index cb9a88c..13972d7 100644 --- a/backend/app/nqi/client.py +++ b/backend/app/nqi/client.py @@ -99,6 +99,7 @@ class LoginChallenge: password: str = "" captcha: str = "" config_ready: bool = False + expected_login: str = "" @dataclass diff --git a/web/src/features/admin/PoolView.vue b/web/src/features/admin/PoolView.vue index e27a0c2..6126c38 100644 --- a/web/src/features/admin/PoolView.vue +++ b/web/src/features/admin/PoolView.vue @@ -1,7 +1,7 @@