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 @@