Auth: nedokoncena registracia sa da dokoncit novym QR kodom
Ucet bez potvrdeneho kodu (auth_token is NULL a totp_last_step == 0) uz neblokuje meno: opakovany register_account vyda novy secret (stary QR prestane platit) a login vyhodi RegistrationIncomplete, na ktoru server odpovie novym QR -- klient sa prepne na registracny tab. Admin statistiky vykazuju nedokoncene registracie osobitne, Hraci celkom pocita len potvrdene ucty. Novy event register v analytike. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+10
-1
@@ -14,7 +14,7 @@ from bridzik import Bridzik, BridzikException, Card
|
||||
from db.db import init_db
|
||||
from api import auth as auth_module, history
|
||||
from api import stats as stats_module
|
||||
from api.auth import AuthError
|
||||
from api.auth import AuthError, RegistrationIncomplete
|
||||
|
||||
|
||||
def _env_bool(name: str, default: bool) -> bool:
|
||||
@@ -415,6 +415,15 @@ async def confirm_account(sid, username, code):
|
||||
async def login(sid, username, code):
|
||||
try:
|
||||
identity = await auth_module.login(username, code)
|
||||
except RegistrationIncomplete as exc:
|
||||
# Nedokoncena registracia -> vydame novy QR kod, klient sa prepne
|
||||
# na registracny tab a pouzivatel ju moze dokoncit.
|
||||
try:
|
||||
data = await auth_module.register_account(username)
|
||||
except AuthError as exc2:
|
||||
return await send_error(sid, str(exc2))
|
||||
await sio.emit("register_account", data, to=sid)
|
||||
return await send_error(sid, str(exc))
|
||||
except AuthError as exc:
|
||||
return await send_error(sid, str(exc))
|
||||
accounts[sid] = {"player_id": identity["player_id"], "username": identity["username"]}
|
||||
|
||||
Reference in New Issue
Block a user