feat(backend,waiter,terminal,manager): sign-in: ask before signing a waiter's other phone out, usernames on paired screens

- auth.single_session_waiter gains 'ask', the new default (Alembic 0051 moves venues on 'off'
  to it): a second phone gets auth.session_elsewhere {device, since}; Continue retries with
  replace=true and the first phone is signed out at once (live session.ended, reason
  "replaced") and says why on its sign-in page. Only phones count (terminal sessions are
  their own client). refuse_new / end_old unchanged.
- auth.session_ended now carries the reason; the waiter app keeps it until the next sign-in.
- The waiter app sends queued offline ops on every (re)connection, so an order queued on a
  phone that was signed out by another goes out after the next sign-in there (e2e checked).
- auth.terminal_require_username (venue) + Device.require_username (per device, wins):
  GET /api/devices/me/users lists nobody, the screen asks for a username then PIN/password,
  a picked user_id is refused (auth.username_required), "tap" falls back to PIN.
- Manager: Sign-in settings (ask, the new switch), the device dialog's usernames choice.

Plan platform-v2 6F.7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 12:51:37 +02:00
co-authored by Claude Opus 5.5
parent 3eeafb565a
commit 7706bf2470
31 changed files with 494 additions and 41 deletions
+24
View File
@@ -308,6 +308,30 @@ try {
await api('POST', `/api/auth/sessions/${sid}/end`, { token: boss })
r.check('session ended by a manager → the screen is back at sign-in at once', await shown(page, 'sign-in-screen', 8000))
// ── 6F.7: usernames on paired screens (venue setting, the device's own choice wins) ──
await api('PUT', '/api/settings/auth.terminal_require_username', { token: boss, body: { value: 'true' } })
r.check('6F.7: usernames on → the screen lists nobody and asks for a username (live)',
await shown(page, 'username-form', 8000) && await page.getByTestId('user-grid').count() === 0)
await page.screenshot({ path: path.join(OUT, 'terminal-username.png') })
const byName = async name => {
await page.getByTestId('username-input').fill(name)
await page.getByRole('button', { name: 'Next' }).click()
await page.getByLabel('Password').fill('password')
await page.getByRole('button', { name: 'Sign in' }).click()
}
await byName('nobody_here')
await sleep(1200)
r.check('6F.7: a wrong username is refused', await page.getByTestId('app-kds').count() === 0 && await page.getByTestId('sign-in-screen').count() === 1)
await page.getByRole('button', { name: 'Back' }).click()
await byName('manager')
r.check('6F.7: username + password signs in', await shown(page, 'app-kds'))
await page.getByRole('button', { name: 'Sign out' }).click()
await api('PATCH', `/api/devices/${kitchen.id}`, { token: boss, body: { require_username: false } })
r.check('6F.7: the device\'s own "no" wins: the names are back', await shown(page, 'user-grid', 8000))
await api('PATCH', `/api/devices/${kitchen.id}`, { token: boss, body: { require_username: null } })
await api('PUT', '/api/settings/auth.terminal_require_username', { token: boss, body: { value: 'false' } })
await shown(page, 'user-grid', 8000)
// ── app off / on ──────────────────────────────────────────────────────────
await api('PUT', '/api/platform/modules/kds', { token: boss, body: { enabled: false } })
r.check('KDS turned off → "turned off" screen, live', await shown(page, 'blocked-screen', 8000)