feat(manager): v2 sign-in (login modes, support access, license notice) and an unlock endpoint for the lock screen
Platform-v2 step 2.6b:
- backend: POST /api/auth/unlock {pin|password} checks the CURRENT session's
user and keeps the session (no new login/token); 5 wrong tries end it
(auth.wrong_pin with attempts_left, then auth.session_ended); bootstrap
gains `login` (manager_mode, autofill_username, support)
- manager LoginPage rewritten on @xenia/ui + i18n: client "manager", password
or PIN pad per setting, remembered/only account card, support access panel
(challenge -> code -> 4 h session, not remembered as an account), notice
when the license runs the free tier (expired/inactive/locked/clock/unverified)
- lock screen on /api/auth/unlock with the shared PinPad
- @xenia/ui PinPad: variable length (minLength/maxLength, OK key, Enter)
- e2e manager.mjs: 33 checks (+ lockout after 5 wrong PINs, PIN login mode,
support access with a wrong then right code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,7 @@ CODES: dict[str, tuple[int, str]] = {
|
||||
"auth.username_required": (422, "Enter your username."),
|
||||
"auth.client_not_allowed": (403, "This account can't use the {client} app."),
|
||||
"auth.session_not_found": (404, "Session not found."),
|
||||
"auth.wrong_pin": (401, "Wrong PIN. {attempts_left} tries left before you are signed out."),
|
||||
"auth.support_not_configured": (503, "Support access isn't set up on this site."),
|
||||
"auth.support_code_invalid": (401, "That support code is wrong or has expired. Ask for a new challenge."),
|
||||
"auth.support_rate_limited": (429, "Too many support challenges. Wait a few minutes and try again."),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"""Platform endpoints (APPS_PLATFORM §4.1, §7.2, §9): /api/platform/...
|
||||
|
||||
GET /bootstrap what every frontend loads first: venue (name, tz, language,
|
||||
currency), the effective modules, and, if logged in, the user,
|
||||
currency), the effective modules, the license state, the login
|
||||
settings a login screen needs, and, if logged in, the user,
|
||||
their language and permission keys. Works without login (login
|
||||
screens need the venue language and zone).
|
||||
GET /modules the full catalogue with each module's state (logged in).
|
||||
@@ -75,6 +76,16 @@ def _module_out(m, enabled: dict, effective: frozenset) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def _login_info(db: Session) -> dict:
|
||||
from config import settings as cfg
|
||||
from core import sessions
|
||||
return {
|
||||
"manager_mode": sessions.manager_login_mode(db), # password | pin
|
||||
"autofill_username": _setting(db, "security.autofill_username", "true") == "true",
|
||||
"support": bool(cfg.SUPPORT_SECRET and cfg.SITE_ID), # "Support access" is offered
|
||||
}
|
||||
|
||||
|
||||
@router.get("/bootstrap", dependencies=[Depends(public())])
|
||||
def bootstrap(
|
||||
request: Request,
|
||||
@@ -98,6 +109,8 @@ def bootstrap(
|
||||
},
|
||||
"modules": [{"key": m.key, "kind": m.kind} for m in registry().values() if m.key in effective],
|
||||
"license": {"mode": entitlements.current().mode, "reason": entitlements.current().reason},
|
||||
# what a login screen needs before anyone is signed in (plan step 2.6b)
|
||||
"login": _login_info(db),
|
||||
"languages": list(i18n.SUPPORTED_LANGUAGES),
|
||||
"user": None,
|
||||
"language": i18n.venue_language(),
|
||||
|
||||
Reference in New Issue
Block a user