diff --git a/Client/src/Components/Inputs/Field/index.jsx b/Client/src/Components/Inputs/Field/index.jsx index 0b2fe56fe..335ed178f 100644 --- a/Client/src/Components/Inputs/Field/index.jsx +++ b/Client/src/Components/Inputs/Field/index.jsx @@ -48,6 +48,7 @@ const Field = forwardRef( placeholder, value, onChange, + onInput, error, disabled, }, @@ -87,6 +88,7 @@ const Field = forwardRef( multiline={type === "description"} rows={type === "description" ? 4 : 1} value={value} + onInput={onInput} onChange={onChange} disabled={disabled} inputRef={ref} @@ -176,6 +178,8 @@ const Field = forwardRef( } ); +Field.displayName = "Field"; + Field.propTypes = { type: PropTypes.oneOf(["text", "password", "url", "email", "description"]), id: PropTypes.string.isRequired, @@ -189,6 +193,7 @@ Field.propTypes = { placeholder: PropTypes.string, value: PropTypes.string.isRequired, onChange: PropTypes.func, + onInput: PropTypes.func, error: PropTypes.string, disabled: PropTypes.bool, }; diff --git a/Client/src/Pages/Auth/Login.jsx b/Client/src/Pages/Auth/Login.jsx index ecdd27060..b962fbb9a 100644 --- a/Client/src/Pages/Auth/Login.jsx +++ b/Client/src/Pages/Auth/Login.jsx @@ -129,6 +129,7 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => { placeholder="jordan.ellis@domain.com" autoComplete="email" value={form.email} + onInput={(e) => (e.target.value = e.target.value.toLowerCase())} onChange={onChange} error={errors.email} ref={inputRef} diff --git a/Client/src/Pages/Auth/Register/Register.jsx b/Client/src/Pages/Auth/Register/Register.jsx index a06075b5a..4680c1821 100644 --- a/Client/src/Pages/Auth/Register/Register.jsx +++ b/Client/src/Pages/Auth/Register/Register.jsx @@ -226,6 +226,7 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => { placeholder="jordan.ellis@domain.com" autoComplete="email" value={form.email} + onInput={(e) => (e.target.value = e.target.value.toLowerCase())} onChange={onChange} error={errors.email} ref={inputRef} diff --git a/Client/src/Validation/validation.js b/Client/src/Validation/validation.js index ab2501199..35d47d6b1 100644 --- a/Client/src/Validation/validation.js +++ b/Client/src/Validation/validation.js @@ -49,6 +49,13 @@ const credentials = joi.object({ .string() .trim() .email({ tlds: { allow: false } }) + .custom((value, helpers) => { + const lowercasedValue = value.toLowerCase(); + if (value !== lowercasedValue) { + return helpers.message("Email must be in lowercase"); + } + return lowercasedValue; + }) .messages({ "string.empty": "Email is required", "string.email": "Must be a valid email address", @@ -72,14 +79,10 @@ const credentials = joi.object({ }); const monitorValidation = joi.object({ - url: joi - .string() - .uri({ allowRelative: true }) - .trim() - .messages({ - "string.empty": "This field is required.", - "string.uri": "The URL you provided is not valid.", - }), + url: joi.string().uri({ allowRelative: true }).trim().messages({ + "string.empty": "This field is required.", + "string.uri": "The URL you provided is not valid.", + }), name: joi.string().trim().max(50).allow("").messages({ "string.max": "This field should not exceed the 50 characters limit.", }), diff --git a/Docker/.gitignore b/Docker/.gitignore index 80c983e6f..89aa6bfac 100644 --- a/Docker/.gitignore +++ b/Docker/.gitignore @@ -2,6 +2,5 @@ !build_images.sh mongo/data/* redis/data/* -nginx/* -certbot/* -*.env \ No newline at end of file +*.env +certbot/* \ No newline at end of file diff --git a/Server/validation/joi.js b/Server/validation/joi.js index 26e62a6db..4f8042e12 100644 --- a/Server/validation/joi.js +++ b/Server/validation/joi.js @@ -16,7 +16,17 @@ const roleValidatior = (role) => (value, helpers) => { //**************************************** const loginValidation = joi.object({ - email: joi.string().email().required(), + email: joi + .string() + .email() + .required() + .custom((value, helpers) => { + const lowercasedValue = value.toLowerCase(); + if (value !== lowercasedValue) { + return helpers.message("Email must be in lowercase"); + } + return lowercasedValue; + }), password: joi .string() .min(8) @@ -35,7 +45,17 @@ const registerValidation = joi.object({ .string() .required() .pattern(/^[A-Za-z]+$/), - email: joi.string().email().required(), + email: joi + .string() + .email() + .required() + .custom((value, helpers) => { + const lowercasedValue = value.toLowerCase(); + if (value !== lowercasedValue) { + return helpers.message("Email must be in lowercase"); + } + return lowercasedValue; + }), password: joi .string() .min(8)