mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-18 23:48:43 -05:00
fix client/server validation
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -420,8 +420,8 @@ const updateAppSettingsBodyValidation = joi.object({
|
||||
systemEmailAddress: joi.string().allow(""),
|
||||
systemEmailPassword: joi.string().allow(""),
|
||||
systemEmailUser: joi.string().allow(""),
|
||||
systemEmailConnectionHost: joi.string().allow("").optional(),
|
||||
systemEmailTLSServername: joi.string().allow("").optional(),
|
||||
systemEmailConnectionHost: joi.string().allow(""),
|
||||
systemEmailTLSServername: joi.string().allow(""),
|
||||
systemEmailSecure: joi.boolean(),
|
||||
systemEmailPool: joi.boolean(),
|
||||
systemEmailIgnoreTLS: joi.boolean(),
|
||||
@@ -430,10 +430,10 @@ const updateAppSettingsBodyValidation = joi.object({
|
||||
|
||||
globalThresholds: joi
|
||||
.object({
|
||||
cpu: joi.number().min(1).max(100).allow("").optional(),
|
||||
memory: joi.number().min(1).max(100).allow("").optional(),
|
||||
disk: joi.number().min(1).max(100).allow("").optional(),
|
||||
temperature: joi.number().min(1).max(150).allow("").optional(),
|
||||
cpu: joi.number().min(1).max(100).allow(""),
|
||||
memory: joi.number().min(1).max(100).allow(""),
|
||||
disk: joi.number().min(1).max(100).allow(""),
|
||||
temperature: joi.number().min(1).max(150).allow(""),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user