fix: always send device config on save — sync toggle now works both ways

This commit is contained in:
Mathieu Moran
2026-08-12 00:16:57 -04:00
parent 79222c8bb5
commit 69109762a8
2 changed files with 18 additions and 16 deletions
+7 -3
View File
@@ -36,10 +36,14 @@ def update_device_config(body, errors):
# 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).
# Toggling off is always allowed — don't error on locked fields
# (the JS always sends them alongside the toggle).
return errors
# User cannot edit locked fields while syncing from server.
# Sync is staying enabled — locked fields are ignored silently.
# The JS always sends them; rejecting would break the save flow.
if "sync_enabled" in body and body["sync_enabled"]:
return errors
# User tried to edit locked fields without the sync toggle — reject.
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