diff --git a/Client/src/Pages/AdvancedSettings/index.jsx b/Client/src/Pages/AdvancedSettings/index.jsx
index d5ac22b26..836722db6 100644
--- a/Client/src/Pages/AdvancedSettings/index.jsx
+++ b/Client/src/Pages/AdvancedSettings/index.jsx
@@ -36,6 +36,7 @@ const AdvancedSettings = ({ isAdmin }) => {
systemEmailAddress: "",
systemEmailPassword: "",
jwtTTL: "",
+ jwtTTLUnits: "days",
dbType: "",
redisHost: "",
redisPort: "",
@@ -68,12 +69,30 @@ const AdvancedSettings = ({ isAdmin }) => {
warn: 4,
};
+ const unitItems = [
+ { _id: 1, name: "days" },
+ { _id: 2, name: "weeks" },
+ { _id: 3, name: "months" }
+ ];
+
+ const unitItemLookup = {
+ days: 1,
+ weeks: 2,
+ months: 3,
+ };
+
const handleLogLevel = (e) => {
const id = e.target.value;
const newLogLevel = logItems.find((item) => item._id === id).name;
setLocalSettings({ ...localSettings, logLevel: newLogLevel });
};
+ const handleJWTTTLUnits = (e) => {
+ const id = e.target.value;
+ const newUnits = unitItems.find((item) => item._id === id).name;
+ setLocalSettings({ ...localSettings, jwtTTLUnits: newUnits });
+ };
+
const handleBlur = (event) => {
const { value, id } = event.target;
const { error } = advancedSettingsValidation.validate(
@@ -82,11 +101,9 @@ const AdvancedSettings = ({ isAdmin }) => {
abortEarly: false,
}
);
- if (error) {
- setErrors((prev) => {
- return buildErrors(prev, id, error);
- });
- }
+ setErrors((prev) => {
+ return buildErrors(prev, id, error);
+ });
};
const handleChange = (event) => {
const { value, id } = event.target;
@@ -209,8 +226,8 @@ const AdvancedSettings = ({ isAdmin }) => {
- {
onBlur={handleBlur}
error={errors.jwtTTL}
/>
+
{
- // test against regx start with a number followed by number or .,
- //ends with d or h
- const regex = /^[1-9]+\d*(d|h)$/;
- const found = value.match(regex);
- if (!found) {
- return helpers.message(
- "JWT TTL should start with a non zero number and ends with 'd' or 'h'."
- );
+ if (value == 0) {
+ return helpers.message("JWT TTL unit is required.");
}
return value;
- }),
+ }),
dbType: joi.string().trim().messages({
"string.empty": "DB type is required.",
}),