fix: disabling sync via settings page no longer returns spurious error 400
This commit is contained in:
@@ -33,12 +33,15 @@ def update_device_config(body, errors):
|
||||
# Check if sync is enabled; if so, only allow sync-related updates
|
||||
sync_enabled = _get_sync_enabled()
|
||||
if sync_enabled:
|
||||
# User cannot edit these fields if syncing from server
|
||||
if any(k in body for k in ["owner_name", "car_model", "avatar_path"]):
|
||||
errors["error"] = "Cannot edit device config while server sync is enabled. Server is source of truth."
|
||||
# Allow toggling sync_enabled off
|
||||
if "sync_enabled" in body and not body["sync_enabled"]:
|
||||
_set_sync_enabled(False)
|
||||
# Toggling off is always allowed — don't return error even if
|
||||
# other locked fields are in the body (the JS always sends them).
|
||||
return errors
|
||||
# User cannot edit locked fields while syncing from server.
|
||||
if any(k in body for k in ["owner_name", "car_model", "avatar_path"]):
|
||||
errors["error"] = "Cannot edit device config while server sync is enabled. Server is source of truth."
|
||||
return errors
|
||||
|
||||
# Not syncing: allow all edits
|
||||
|
||||
Reference in New Issue
Block a user