mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-02 16:59:32 +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
@@ -599,9 +599,16 @@ Object.assign(CodemanApp.prototype, {
|
||||
localStorage.setItem('codeman-respawn-presets', JSON.stringify(custom));
|
||||
// Persist to server (cross-device sync). Not for a non-admin in multi-user mode: the
|
||||
// presets are a key of the server-wide settings.json there, and its PUT is admin-only
|
||||
// (403), so they stay on this device (_settingsReadOnly, settings-ui.js).
|
||||
if (this._settingsReadOnly?.()) return;
|
||||
this._apiPut('/api/settings', { respawnPresets: custom }).catch(() => {});
|
||||
// (403), so they are kept as their own on this device and win 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.
|
||||
if (this._settingsReadOnly?.()) {
|
||||
this._rememberOwnSetting?.('respawnPresets', custom);
|
||||
return;
|
||||
}
|
||||
this._apiPut('/api/settings', { respawnPresets: custom })
|
||||
.then((res) => this._noteSettingsWriteRefusal?.(res))
|
||||
.catch(() => {});
|
||||
},
|
||||
|
||||
renderPresetDropdown() {
|
||||
|
||||
Reference in new issue
Block a user