fix: 平台登录失败后刷新验证码

This commit is contained in:
2026-10-30 12:09:20 +08:00
parent 559548d577
commit 811dc448cb
3 changed files with 51 additions and 11 deletions
+8 -9
View File
@@ -13,7 +13,7 @@ from app.config import installed, result_dir
from app.install import InstallError, perform_install
from app.db import get_session, session_scope
from app.models import AppSetting, CollectionSource, ExportTask, NqiAccount, User, utcnow
from app.nqi.client import NqiAuthError, NqiClient, NqiError, needs_captcha
from app.nqi.client import NqiAuthError, NqiClient, NqiError
from app.nqi.flows import drop, purge, remember, take
from app.security import hash_password, issue_token, verify_password
from app.tasks.runner import check_concurrency, check_period, check_refresh, enqueue_export
@@ -233,14 +233,13 @@ async def nqi_finish(body: dict) -> dict:
user = await client.submit_login(challenge, sms_code)
except NqiError as exc:
message = str(exc)
if needs_captcha(message):
challenge.config_ready = False
try:
await client.refresh_captcha(challenge)
except NqiError:
pass
return {**_captcha_body(session_id, challenge), "status": "need_captcha", "message": message}
raise _bad(message) from exc
challenge.config_ready = False
challenge.captcha = ""
try:
await client.refresh_captcha(challenge)
except NqiError:
pass
return {**_captcha_body(session_id, challenge), "status": "need_captcha", "message": message}
challenge.password = ""
cookies = client.export_cookies()
await client.aclose()