mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-17 03:39:33 +01:00
fix(multi-user): read a refused settings write as admin-only in the browser
Two gaps in how a regular user's browser handled the admin-only settings writes: - The role comes from GET /api/me, which answers after page load, and on a failed request admin-ui.js falls back to a single-user admin. A save made then was sent, came back 403, and still said "Settings saved", while the refused server-wide change stayed on the device. A 403 FORBIDDEN on a settings write now ends that save like a known non-admin's: synced keys back to the server's value, the one admin-only notice, and the page is read-only from then on (_noteSettingsWriteRefusal). The display-key list moved into one method (_displaySettingKeySet), so that split no longer depends on GET /api/settings having loaded. - A regular user's run mode and respawn presets were skipped for the server but overwritten by the server's on the next page load, while "Saved preset" said otherwise. They are now kept as that user's own on the device and put back over the server's after the settings load and on codeman:me (_rememberOwnSetting, _applyOwnSettings). Admins and single-user mode are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
24a1c6c427
commit
5a297cd3e4
5 files changed
+325
-52
No files matched your search
@@ -719,8 +719,17 @@ Object.assign(CodemanApp.prototype, {
|
||||
try { localStorage.setItem('codeman_runMode', mode); } catch {}
|
||||
this._applyRunMode();
|
||||
// Sync to server for cross-device persistence. Not for a non-admin in multi-user mode,
|
||||
// where settings.json is server-wide and its PUT admin-only: the mode stays on this device.
|
||||
if (!this._settingsReadOnly?.()) this._apiPut('/api/settings', { runMode: mode }).catch(() => {});
|
||||
// where settings.json is server-wide and its PUT admin-only: the mode is kept as their own
|
||||
// on this device and wins over the server's on the next load (_rememberOwnSetting,
|
||||
// settings-ui.js). A PUT refused that way (sent before the role was known) marks the page
|
||||
// read-only for the writes after it (_noteSettingsWriteRefusal).
|
||||
if (this._settingsReadOnly?.()) {
|
||||
this._rememberOwnSetting?.('runMode', mode);
|
||||
} else {
|
||||
this._apiPut('/api/settings', { runMode: mode })
|
||||
.then((res) => this._noteSettingsWriteRefusal?.(res))
|
||||
.catch(() => {});
|
||||
}
|
||||
// Close menu
|
||||
document.getElementById('runModeMenu')?.classList.remove('active');
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user