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
@@ -1,7 +1,8 @@
// Sign-in settings (plan step 2.6f, APPS_PLATFORM D-8, D-9). Backend-only until now:
// auth.manager_login_mode, auth.waiter_login_mode, auth.waiter_require_username,
// auth.default_login_mode (paired devices; a device can choose its own on the Devices page),
// auth.single_session_manager / _waiter, and security.autofill_username (the sign-in page).
// auth.single_session_manager / _waiter, security.autofill_username (the sign-in page) and
// auth.idle_days (sign out after N days without use, 0 = never; owner decision 2026-11-14, 2.99d).
// Replaces the v1 "login method" card, whose setting (security.login_method) no longer exists.
import { useId } from 'react'
import { useTranslation } from '@xenia/i18n'
@@ -10,6 +11,7 @@ import { SettingRow, SettingsCard } from './SettingsCard'
import { useSettings } from './useSettings'
const SESSION_RULES = ['off', 'refuse_new', 'end_old']
const IDLE_DAYS = ['7', '14', '30', '60', '90', '0']
export default function SignInSettings() {
const { t } = useTranslation('manager')
@@ -19,6 +21,7 @@ export default function SignInSettings() {
const idDevice = useId()
const idSingleManager = useId()
const idSingleWaiter = useId()
const idIdle = useId()
if (s.loading) return <div className="py-8 flex justify-center"><Spinner /></div>
const opts = (keys, prefix) => keys.map(k => ({ value: k, label: t(`${prefix}.${k}`) }))
@@ -31,6 +34,9 @@ export default function SignInSettings() {
onChange={v => s.save(key, v ? 'true' : 'false')} data-testid={`setting-${key}`} />
)
const waiterMode = s.get('auth.waiter_login_mode', 'pin')
const idle = s.get('auth.idle_days', '14')
const idleOptions = (IDLE_DAYS.includes(idle) ? IDLE_DAYS : [...IDLE_DAYS.slice(0, -1), idle, '0']) // keep a value set elsewhere
.map(d => ({ value: d, label: d === '0' ? t('settings.signIn.idleNever') : t('settings.signIn.idleDays', { count: Number(d) }) }))
return (
<SettingsCard title={t('settings.signIn.title')} description={t('settings.signIn.intro')} testId="settings-sign-in">
@@ -56,6 +62,9 @@ export default function SignInSettings() {
<SettingRow label={t('settings.signIn.singleWaiter')} htmlFor={idSingleWaiter}>
{select('auth.single_session_waiter', 'off', opts(SESSION_RULES, 'settings.session'), idSingleWaiter)}
</SettingRow>
<SettingRow label={t('settings.signIn.idle')} htmlFor={idIdle} hint={t('settings.signIn.idleHint')}>
{select('auth.idle_days', '14', idleOptions, idIdle)}
</SettingRow>
</SettingsCard>
)
}