- handle form save for jwtTTL

- update validation for advanced settings page black list some unused fields which causing errors
This commit is contained in:
Shemy Gan committed 2024-10-24 11:31:10 -04:00
1 parent a4344b89a2
commit 57edff36c9
3 files changed
+50 -23

No files matched your search

+15 -3
View File
@@ -15,10 +15,22 @@ const hasValidationErrors = (form, validation, setErrors) => {
if (error) {
const newErrors = {};
error.details.forEach((err) => {
newErrors[err.path[0]] = err.message?? "Validation error";
if (
![
"clientHost",
"refreshTokenSecret",
"dbConnectionString",
"refreshTokenTTL",
"jwtTTL",
].includes(err.path[0])
) {
newErrors[err.path[0]] = err.message ?? "Validation error";
}
});
setErrors(newErrors);
return true;
if (Object.keys(newErrors).length > 0) {
setErrors(newErrors);
return true;
} else return false;
}
return false;
};
+7 -5
View File
@@ -138,18 +138,20 @@ const advancedSettingsValidation = joi.object({
systemEmailPort: joi.string().allow(""),
systemEmailAddress: joi.string().allow(""),
systemEmailPassword: joi.string().allow(""),
jwtTTL: joi.string().trim().messages({
"string.empty": "JWT TTL is required.",
}),
jwtTTLNum: joi
.number()
.messages({
"any.required": "JWT TTL is required.",
}),
jwtTTLUnits: joi
.string()
.trim()
.custom((value, helpers) => {
if (value == 0) {
if( !["days", "hours"].includes(value)) {
return helpers.message("JWT TTL unit is required.");
}
return value;
}),
}),
dbType: joi.string().trim().messages({
"string.empty": "DB type is required.",
}),