forked from retoor/devplacepy
fix: reorder validation check and add saved fields to service config response
The validation error check was placed before the config save operation, causing early returns that skipped persisting valid fields. This moves the error check after saving valid values and adds a "saved" key to the response listing which fields were successfully stored. Also adds autocomplete and password manager attributes to the password input field in the service config form to prevent browser autofill interference.
This commit is contained in:
@@ -68,12 +68,13 @@ class ServiceManager:
|
||||
valid[field.key] = field.to_storage(field.coerce(raw))
|
||||
except ValueError as e:
|
||||
errors[field.key] = str(e)
|
||||
if errors:
|
||||
return {"ok": False, "errors": errors}
|
||||
for key, value in valid.items():
|
||||
set_setting(key, value)
|
||||
logger.info(f"Service {name} config saved ({len(valid)} fields)")
|
||||
return {"ok": True, "errors": {}}
|
||||
if valid:
|
||||
logger.info(f"Service {name} config saved ({len(valid)} fields)")
|
||||
if errors:
|
||||
return {"ok": False, "errors": errors, "saved": list(valid.keys())}
|
||||
return {"ok": True, "errors": {}, "saved": list(valid.keys())}
|
||||
|
||||
def supervise(self) -> None:
|
||||
for svc in self._services.values():
|
||||
|
||||
Reference in New Issue
Block a user