fix client/server validation
This commit is contained in:
1 parent
8cbde4a705
commit
b6765830a5
2 files changed
+21
-8
No files matched your search
@@ -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;
|
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;
|
delete toSubmit.pagespeedApiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveSettings(toSubmit);
|
saveSettings(toSubmit);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -420,8 +420,8 @@ const updateAppSettingsBodyValidation = joi.object({
|
|||||||
systemEmailAddress: joi.string().allow(""),
|
systemEmailAddress: joi.string().allow(""),
|
||||||
systemEmailPassword: joi.string().allow(""),
|
systemEmailPassword: joi.string().allow(""),
|
||||||
systemEmailUser: joi.string().allow(""),
|
systemEmailUser: joi.string().allow(""),
|
||||||
systemEmailConnectionHost: joi.string().allow("").optional(),
|
systemEmailConnectionHost: joi.string().allow(""),
|
||||||
systemEmailTLSServername: joi.string().allow("").optional(),
|
systemEmailTLSServername: joi.string().allow(""),
|
||||||
systemEmailSecure: joi.boolean(),
|
systemEmailSecure: joi.boolean(),
|
||||||
systemEmailPool: joi.boolean(),
|
systemEmailPool: joi.boolean(),
|
||||||
systemEmailIgnoreTLS: joi.boolean(),
|
systemEmailIgnoreTLS: joi.boolean(),
|
||||||
@@ -430,10 +430,10 @@ const updateAppSettingsBodyValidation = joi.object({
|
|||||||
|
|
||||||
globalThresholds: joi
|
globalThresholds: joi
|
||||||
.object({
|
.object({
|
||||||
cpu: joi.number().min(1).max(100).allow("").optional(),
|
cpu: joi.number().min(1).max(100).allow(""),
|
||||||
memory: joi.number().min(1).max(100).allow("").optional(),
|
memory: joi.number().min(1).max(100).allow(""),
|
||||||
disk: joi.number().min(1).max(100).allow("").optional(),
|
disk: joi.number().min(1).max(100).allow(""),
|
||||||
temperature: joi.number().min(1).max(150).allow("").optional(),
|
temperature: joi.number().min(1).max(150).allow(""),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user