diff --git a/backend/app/platform/auth.py b/backend/app/platform/auth.py index 1bbfc28..0992286 100644 --- a/backend/app/platform/auth.py +++ b/backend/app/platform/auth.py @@ -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)