feat: 号池操作列可以重新登录这个账号

This commit is contained in:
2026-11-10 09:08:31 +08:00
parent e3d7a05e0e
commit 339b169f3c
4 changed files with 40 additions and 9 deletions
+11
View File
@@ -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()
+1
View File
@@ -99,6 +99,7 @@ class LoginChallenge:
password: str = ""
captcha: str = ""
config_ready: bool = False
expected_login: str = ""
@dataclass