mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-02 22:49:19 -05:00
added lowercase text onchange
This commit is contained in:
@@ -107,12 +107,13 @@ const TeamPanel = () => {
|
||||
|
||||
const handleChange = (event) => {
|
||||
const { value } = event.target;
|
||||
const newEmail = value?.toLowerCase() || value
|
||||
setToInvite((prev) => ({
|
||||
...prev,
|
||||
email: value,
|
||||
email: newEmail,
|
||||
}));
|
||||
|
||||
const validation = credentials.validate({ email: value }, { abortEarly: false });
|
||||
const validation = credentials.validate({ email: newEmail }, { abortEarly: false });
|
||||
|
||||
setErrors((prev) => {
|
||||
const updatedErrors = { ...prev };
|
||||
@@ -153,7 +154,7 @@ const TeamPanel = () => {
|
||||
|
||||
try {
|
||||
await networkService.sendInvitationToken({
|
||||
email: toInvite.email.toLowerCase(),
|
||||
email: toInvite.email,
|
||||
role: toInvite.role,
|
||||
});
|
||||
closeInviteModal();
|
||||
|
||||
@@ -12,8 +12,7 @@ const initialState = {
|
||||
|
||||
export const register = createAsyncThunk("auth/register", async (form, thunkApi) => {
|
||||
try {
|
||||
const newForm = {...form, email: form.email.toLowerCase()}
|
||||
const res = await networkService.registerUser(newForm);
|
||||
const res = await networkService.registerUser(form);
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
if (error.response.data) {
|
||||
@@ -29,8 +28,7 @@ export const register = createAsyncThunk("auth/register", async (form, thunkApi)
|
||||
|
||||
export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
|
||||
try {
|
||||
const newForm = {...form, email: form.email.toLowerCase()}
|
||||
const res = await networkService.loginUser(newForm);
|
||||
const res = await networkService.loginUser(form);
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
if (error.response && error.response.data) {
|
||||
|
||||
@@ -63,12 +63,13 @@ const Login = () => {
|
||||
const handleChange = (event) => {
|
||||
const { value, id } = event.target;
|
||||
const name = idMap[id];
|
||||
const lowerCasedValue = name === idMap["login-email-input"]? value?.toLowerCase()||value : value
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
[name]: value,
|
||||
[name]: lowerCasedValue,
|
||||
}));
|
||||
|
||||
const { error } = credentials.validate({ [name]: value }, { abortEarly: false });
|
||||
const { error } = credentials.validate({ [name]: lowerCasedValue }, { abortEarly: false });
|
||||
|
||||
setErrors((prev) => {
|
||||
const prevErrors = { ...prev };
|
||||
|
||||
@@ -259,13 +259,14 @@ const Register = ({ isSuperAdmin }) => {
|
||||
const handleChange = (event) => {
|
||||
const { value, id } = event.target;
|
||||
const name = idMap[id];
|
||||
const lowerCasedValue = name === idMap["register-email-input"]? value?.toLowerCase() || value : value
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
[name]: value,
|
||||
[name]: lowerCasedValue,
|
||||
}));
|
||||
|
||||
const { error } = credentials.validate(
|
||||
{ [name]: value },
|
||||
{ [name]: lowerCasedValue },
|
||||
{ abortEarly: false, context: { password: form.password } }
|
||||
);
|
||||
|
||||
|
||||
@@ -65,6 +65,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",
|
||||
|
||||
Reference in New Issue
Block a user