Stop the USB settings page from replacing the kiosk token with "true"
The page saved every field as 'true'/'false', the kiosk device token included, and loaded the token as a boolean. One save of Settings > USB Devices therefore stored the literal word "true" (or "false") as the token, and every kiosk provisioned with the real token got 404 on each request - reported as the kiosk no longer accepting an SSO. Generate + Save never stored the generated value either. The token now loads and saves as text. The server already keeps the stored token when it receives the mask back unchanged. The two switches still save as booleans. The parts kiosk page was not affected.
This commit is contained in:
@@ -114,7 +114,12 @@ async function load () {
|
||||
try {
|
||||
const response = await settingsApi.list({ category: 'usb' })
|
||||
for (const row of (response.data.data || [])) {
|
||||
if (KEYS.includes(row.key)) values.value[row.key] = asBool(row.value)
|
||||
if (!KEYS.includes(row.key)) continue
|
||||
// The token is text (the server sends a mask once set); only the two
|
||||
// switches are booleans.
|
||||
values.value[row.key] = row.key === 'usb_kiosk_token'
|
||||
? (row.value || '')
|
||||
: asBool(row.value)
|
||||
}
|
||||
} catch (loadError) {
|
||||
error.value = 'Could not load USB settings.'
|
||||
@@ -127,7 +132,13 @@ async function save () {
|
||||
error.value = ''
|
||||
try {
|
||||
for (const key of KEYS) {
|
||||
await settingsApi.update(key, values.value[key] ? 'true' : 'false')
|
||||
// Saving the token as true/false replaced the real token with the word
|
||||
// 'true', and every provisioned kiosk then got 404. The server keeps the
|
||||
// stored token when it receives the mask back unchanged.
|
||||
const value = key === 'usb_kiosk_token'
|
||||
? String(values.value[key] ?? '')
|
||||
: (values.value[key] ? 'true' : 'false')
|
||||
await settingsApi.update(key, value)
|
||||
}
|
||||
message.value = 'Settings saved'
|
||||
} catch (saveError) {
|
||||
|
||||
Reference in New Issue
Block a user