feat(waiter): sign-in v2 on the phones (platform-v2 step 4.2)

- Login follows auth.waiter_login_mode / auth.waiter_require_username from the
  bootstrap: name + PIN, name + password, typed username, or a "paired screens
  only" message for tap mode. POST /api/auth/login {client: "waiter"}; a miss
  shows the translated error without a reload.
- POST /api/auth/login-by-id removed; bootstrap login carries waiter_mode and
  waiter_require_username.
- Sign-out ends the session on the server (POST /api/auth/logout), so
  single_session_waiter = refuse_new no longer strands a waiter.
- Lock on the phone: menu "Lock", automatic lock / sign-out after inactivity
  (security.auto_lock*, auto_logout*), unlock with the PIN in the same session,
  lock kept across app restarts (restore() no longer clears it).
- e2e: new waiter.mjs (22 checks) in run-all; android.mjs signs in for real and
  locks/unlocks on the emulator; TLS live check waits for the socket; the
  rediscovery helper re-attaches to a stale WebView handle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 15:25:00 +02:00
co-authored by Claude Opus 5.5
parent 9f5498332a
commit 8299184e3a
14 changed files with 664 additions and 106 deletions
+19 -4
View File
@@ -33,6 +33,7 @@ import InstallAppDialog from './components/InstallAppDialog'
import VenuesPage from './pages/VenuesPage'
import ServerRediscovery from './components/ServerRediscovery'
import BundleSync from './components/BundleSync'
import LockScreen, { IdleGuard } from './components/LockScreen'
import { deliveryMode, getActiveVenue } from './config/server'
// ─── Utility ─────────────────────────────────────────────────────────────────
@@ -275,19 +276,33 @@ function AppLayout() {
return <Outlet />
}
/** Signed-in screens with the idle guard and the lock screen over them (plan step 4.2): the
* lock covers everything, the shift gates included, and what was open stays underneath. */
function ProtectedLayout() {
const token = useAuthStore(s => s.token)
const locked = useAuthStore(s => s.locked)
return (
<>
{token && <IdleGuard />}
{token && locked && <LockScreen />}
<AppLayout />
</>
)
}
// ─── Global helpers ───────────────────────────────────────────────────────────
/** Who is signed in comes with the bootstrap (plan 4.1): online it's the server's answer;
* offline the bootstrap cached for this token keeps the waiter signed in (CS-3). A token the
* server no longer knows comes back with no user: sign out. */
function AuthRehydrator() {
const { token, user, login, logout } = useAuthStore()
const { token, user, restore, logout } = useAuthStore()
const access = useAccess()
useEffect(() => {
if (!token || user) return
if (access.user) login(access.user, token)
if (access.user) restore(access.user)
else if (!access.offline) logout()
}, [token, user, access.user, access.offline, login, logout])
}, [token, user, access.user, access.offline, restore, logout])
return null
}
@@ -461,7 +476,7 @@ function Routed() {
<Route path="/login" element={<LoginGuard><LoginPage /></LoginGuard>} />
<Route path="/offline" element={<OfflinePage />} />
<Route path="/venues" element={deliveryMode() === 'native' ? <VenuesPage /> : <Navigate to="/" replace />} />
<Route element={<AppLayout />}>
<Route element={<ProtectedLayout />}>
<Route index element={<Navigate to="/tables?tab=tables" replace />} />
<Route path="/tables" element={<TableListRoute />} />
<Route path="/tables/:tableId" element={<TableDetailPage />} />