fix: 登录失败时更新 execution,验证码失效则要求重填
This commit is contained in:
@@ -8,7 +8,7 @@ import uuid
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from app.platform.client import NqiError
|
||||
from app.platform.client import NqiError, needs_captcha
|
||||
from app.platform.sessions import available_accounts, remember, resume
|
||||
from app.shared.state import state
|
||||
|
||||
@@ -97,12 +97,16 @@ async def login(body: dict) -> dict:
|
||||
return {"status": "sms_required"}
|
||||
user = await client.submit_login(challenge, sms_code)
|
||||
except NqiError as exc:
|
||||
message = str(exc)
|
||||
if needs_captcha(message):
|
||||
challenge.config_ready = False
|
||||
return {"status": "need_captcha", "message": message}
|
||||
if not challenge.config_ready:
|
||||
try:
|
||||
await client.refresh_captcha(challenge)
|
||||
except NqiError:
|
||||
pass
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
raise HTTPException(status_code=400, detail=message) from exc
|
||||
challenge.password = ""
|
||||
remember(user, client.export_cookies())
|
||||
state.flows.pop(session_id, None)
|
||||
|
||||
Reference in New Issue
Block a user