Merge pull request #3121 from web-engineer/fix/3120-data-leak
3120 remove URL's from data when they are supposed to be disabled
This commit is contained in:
8 files changed
+33
-28
No files matched your search
@@ -56,6 +56,7 @@ const useSaveSettings = ({
|
||||
setEmailPasswordHasBeenReset(false);
|
||||
}
|
||||
setSettingsData(settingsResponse.data.data);
|
||||
|
||||
createToast({ body: t("settingsSuccessSaved") });
|
||||
} catch (error) {
|
||||
createToast({ body: t("settingsFailedToSave") });
|
||||
|
||||
@@ -75,11 +75,6 @@ const Settings = () => {
|
||||
const handleChange = async (e) => {
|
||||
const { name, value, checked } = e.target;
|
||||
|
||||
// Special case for showURL until handled properly in the backend
|
||||
if (name === "showURL") {
|
||||
dispatch(setShowURL(value));
|
||||
return;
|
||||
}
|
||||
let newValue;
|
||||
if (
|
||||
name === "systemEmailIgnoreTLS" ||
|
||||
@@ -90,6 +85,12 @@ const Settings = () => {
|
||||
) {
|
||||
newValue = checked;
|
||||
}
|
||||
|
||||
// Ensure showURL is a proper boolean
|
||||
if (name === "showURL") {
|
||||
newValue = value === true || value === "true";
|
||||
}
|
||||
|
||||
// Build next state early
|
||||
const newSettingsData = {
|
||||
...settingsData,
|
||||
@@ -147,29 +148,22 @@ const Settings = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate
|
||||
const { error } = settingsValidation.validate(newSettingsData.settings, {
|
||||
abortEarly: false,
|
||||
});
|
||||
if (!error || error.details.length === 0) {
|
||||
setErrors({});
|
||||
} else {
|
||||
const newErrors = {};
|
||||
error.details.forEach((err) => {
|
||||
newErrors[err.path[0]] = err.message;
|
||||
});
|
||||
setErrors(newErrors);
|
||||
}
|
||||
|
||||
setSettingsData(newSettingsData);
|
||||
|
||||
// Update Redux immediately for UI feedback
|
||||
if (name === "showURL") {
|
||||
dispatch(setShowURL(newValue));
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
// Validate
|
||||
const { error } = settingsValidation.validate(settingsData.settings, {
|
||||
abortEarly: false,
|
||||
});
|
||||
if (!error || error.details.length === 0) {
|
||||
setErrors({});
|
||||
saveSettings(settingsData?.settings);
|
||||
} else {
|
||||
const newErrors = {};
|
||||
error.details.forEach((err) => {
|
||||
@@ -178,7 +172,6 @@ const Settings = () => {
|
||||
|
||||
setErrors(newErrors);
|
||||
}
|
||||
saveSettings(settingsData?.settings);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -328,6 +328,7 @@ const settingsValidation = joi.object({
|
||||
systemEmailIgnoreTLS: joi.boolean(),
|
||||
systemEmailRequireTLS: joi.boolean(),
|
||||
systemEmailRejectUnauthorized: joi.boolean(),
|
||||
showURL: joi.boolean().optional(),
|
||||
globalThresholds: joi
|
||||
.object({
|
||||
cpu: joi.number().min(1).max(100).allow("").optional(),
|
||||
|
||||
Reference in new issue
Block a user