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:
@@ -3,6 +3,8 @@
|
||||
// auth.default_login_mode (paired devices; a device can choose its own on the Devices 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).
|
||||
// 6F.7: waiters get 'ask' (the default: the phone asks before signing the other one out; only
|
||||
// phones count), and auth.terminal_require_username (paired screens list nobody).
|
||||
// Replaces the v1 "login method" card, whose setting (security.login_method) no longer exists.
|
||||
import { useId } from 'react'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
@@ -11,6 +13,7 @@ import { SettingRow, SettingsCard } from './SettingsCard'
|
||||
import { useSettings } from './useSettings'
|
||||
|
||||
const SESSION_RULES = ['off', 'refuse_new', 'end_old']
|
||||
const WAITER_SESSION_RULES = ['ask', 'off', 'refuse_new', 'end_old']
|
||||
const IDLE_DAYS = ['7', '14', '30', '60', '90', '0']
|
||||
|
||||
export default function SignInSettings() {
|
||||
@@ -56,11 +59,14 @@ export default function SignInSettings() {
|
||||
<SettingRow label={t('settings.signIn.device')} htmlFor={idDevice} hint={t('settings.signIn.deviceHint')} tip={t('settings.signIn.deviceTip')}>
|
||||
{select('auth.default_login_mode', 'pin', opts(['pin', 'password', 'tap', 'none'], 'settings.mode'), idDevice)}
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.signIn.terminalUsername')} hint={t('settings.signIn.terminalUsernameHint')} tip={t('settings.signIn.terminalUsernameTip')}>
|
||||
{toggle('auth.terminal_require_username', 'false', t('settings.signIn.terminalUsername'))}
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.signIn.singleManager')} htmlFor={idSingleManager} tip={t('settings.signIn.singleTip')}>
|
||||
{select('auth.single_session_manager', 'off', opts(SESSION_RULES, 'settings.session'), idSingleManager)}
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.signIn.singleWaiter')} htmlFor={idSingleWaiter} tip={t('settings.signIn.singleTip')}>
|
||||
{select('auth.single_session_waiter', 'off', opts(SESSION_RULES, 'settings.session'), idSingleWaiter)}
|
||||
<SettingRow label={t('settings.signIn.singleWaiter')} htmlFor={idSingleWaiter} hint={t('settings.signIn.singleWaiterHint')} tip={t('settings.signIn.singleWaiterTip')}>
|
||||
{select('auth.single_session_waiter', 'ask', opts(WAITER_SESSION_RULES, 'settings.session'), idSingleWaiter)}
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.signIn.idle')} htmlFor={idIdle} hint={t('settings.signIn.idleHint')} tip={t('settings.signIn.idleTip')}>
|
||||
{select('auth.idle_days', '14', idleOptions, idIdle)}
|
||||
|
||||
@@ -277,10 +277,24 @@ function PairDialog({ apps, usage, devices, appName, limitLabel, initialApp, onC
|
||||
)
|
||||
}
|
||||
|
||||
/** Usernames on this screen (6F.7): the venue's choice, or its own yes / no. */
|
||||
function usernameOptions(device, t) {
|
||||
// the venue's value = what applies when the device has no choice of its own
|
||||
const venue = device.require_username == null ? device.effective_require_username : null
|
||||
const yes = t('devices.form.usernamesYes')
|
||||
const no = t('devices.form.usernamesNo')
|
||||
return [
|
||||
{ value: '', label: venue == null ? t('devices.signIn.defaultPlain') : t('devices.form.usernamesDefault', { value: venue ? yes : no }) },
|
||||
{ value: 'true', label: yes },
|
||||
{ value: 'false', label: no },
|
||||
]
|
||||
}
|
||||
|
||||
function EditDialog({ device, apps, devices, onClose, onSave }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const [name, setName] = useState(device.name)
|
||||
const [mode, setMode] = useState(device.login_mode || '')
|
||||
const [usernames, setUsernames] = useState(device.require_username == null ? '' : String(device.require_username))
|
||||
const [link, setLink] = useState(device.linked_device_id ? String(device.linked_device_id) : '')
|
||||
const app = apps.find(a => a.key === device.app_key)
|
||||
const fields = app?.device_app?.config || []
|
||||
@@ -293,6 +307,7 @@ function EditDialog({ device, apps, devices, onClose, onSave }) {
|
||||
e.preventDefault()
|
||||
if (!name.trim() || busy) return
|
||||
run({ name: name.trim(), login_mode: mode || null, linked_device_id: link ? Number(link) : null,
|
||||
...(modes ? { require_username: usernames === '' ? null : usernames === 'true' } : {}),
|
||||
...(fields.length ? { config } : {}) })
|
||||
}
|
||||
|
||||
@@ -308,6 +323,12 @@ function EditDialog({ device, apps, devices, onClose, onSave }) {
|
||||
<Select value={mode} onChange={e => setMode(e.target.value)} options={modes} />
|
||||
</Field>
|
||||
)}
|
||||
{modes && (
|
||||
<Field label={t('devices.form.usernames')} info={<InfoTip>{t('devices.form.usernamesTip')}</InfoTip>}>
|
||||
<Select value={usernames} onChange={e => setUsernames(e.target.value)} data-testid="device-usernames"
|
||||
options={usernameOptions(device, t)} />
|
||||
</Field>
|
||||
)}
|
||||
{targets.length > 0 && (
|
||||
<Field label={t('devices.form.link')} hint={t('devices.form.linkHint')}>
|
||||
<Select value={link} onChange={e => setLink(e.target.value)}
|
||||
|
||||
Reference in New Issue
Block a user