feat(backend): sign people out after N days without use (auth.idle_days, default 14)

Platform-v2 step 2.99d, owner decision 2026-11-14.
- New core setting auth.idle_days (int, default 14, 0 = never). A manager, waiter or
  paired-device session unused for that long ends with reason "idle" on its next
  request (sessions.validate) or when someone opens "Signed in now"
  (sessions.end_idle in GET /api/auth/sessions). Support keeps its own 4 h expiry.
- Manager: Settings -> Sign-in & security -> "Sign people out after" (7/14/30/60/90
  days / Never; a value set elsewhere is kept); "Signed in now" names the reason.
  Texts en/el.
- Tests: backend 284 (+ 14-day default, list drops idle ones, setting incl. 0);
  manager e2e checks the default and saving 30. The support-access check that
  failed once in ~8 runs now saves a screenshot and the page's alert text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 13:38:00 +02:00
co-authored by Claude Opus 5.5
parent cc4e76019b
commit f1f20f7bba
8 changed files with 119 additions and 6 deletions
+10 -1
View File
@@ -277,7 +277,10 @@ try {
await page.getByLabel("Support's code").fill(codeFor(siteSecret(SUPPORT_MASTER, 'test-site-1'), 'test-site-1', challenge))
await page.getByRole('button', { name: 'Open support session' }).click()
await page.waitForURL(u => u.pathname === '/dashboard', { timeout: 10_000 }).catch(() => {})
r.check('support: the right code opens a session', new URL(page.url()).pathname === '/dashboard', page.url())
const supportOk = new URL(page.url()).pathname === '/dashboard'
if (!supportOk) await page.screenshot({ path: path.join(OUT, 'manager-support-access-FAILED.png') }) // seen failing once in ~8 runs (2.99a, 2.99d)
r.check('support: the right code opens a session', supportOk,
supportOk ? page.url() : `${page.url()} alert=${JSON.stringify(await page.getByRole('alert').allTextContents().catch(() => []))}`)
await page.evaluate(() => { localStorage.removeItem('manager_token') })
await uiLogin(page, 'password')
await page.waitForURL(u => u.pathname === '/dashboard', { timeout: 10_000 }).catch(() => {})
@@ -481,6 +484,12 @@ try {
r.check('settings: one session per waiter → "sign out the older one"', await settingValue('auth.single_session_waiter') === 'end_old' &&
await settingValue('auth.manager_login_mode') === 'password' && await settingValue('auth.waiter_login_mode') === 'pin')
await page.getByTestId('setting-auth.single_session_waiter').selectOption('off')
const idleSel = page.getByTestId('setting-auth.idle_days')
const idleDefault = await idleSel.inputValue()
await idleSel.selectOption('30')
await sleep(800)
r.check('settings: sign out after 14 days by default; 30 days is saved', idleDefault === '14' && await settingValue('auth.idle_days') === '30', idleDefault)
await idleSel.selectOption('14')
await page.getByText('Venue & language', { exact: true }).click()
const tzSelect = page.getByTestId('setting-venue.timezone')