fix client/server validation

This commit is contained in:
Alex Holliday committed 2026-02-18 19:13:52 +00:00
1 parent 8cbde4a705
commit b6765830a5
2 files changed
+21 -8

No files matched your search

+15 -2
View File
@@ -103,12 +103,25 @@ const Settings = () => {
})
);
if (!form.formState.dirtyFields.systemEmailPassword) {
// Handle password field:
// - If emailPasswordHasBeenReset is true, ALWAYS include (even if empty to unset)
// - Otherwise, only include if dirty (user typed something)
if (emailPasswordHasBeenReset) {
// Keep password field (even if empty) to allow unsetting
// toSubmit.systemEmailPassword is already in toSubmit
} else if (!form.formState.dirtyFields.systemEmailPassword) {
// Not in reset mode and not dirty -> exclude (no changes)
delete toSubmit.systemEmailPassword;
}
if (!form.formState.dirtyFields.pagespeedApiKey) {
// Handle API key field (same logic)
if (apiKeyHasBeenReset) {
// Keep API key field (even if empty) to allow unsetting
} else if (!form.formState.dirtyFields.pagespeedApiKey) {
// Not in reset mode and not dirty -> exclude (no changes)
delete toSubmit.pagespeedApiKey;
}
saveSettings(toSubmit);
};