added min password length rule
This commit is contained in:
@@ -37,7 +37,13 @@ export default function ChangePassword({
|
|||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
if (newPassword == "" || newPassword2 == "") {
|
if (newPassword == "" || newPassword2 == "") {
|
||||||
toast.error("Please fill all the fields.");
|
toast.error("Please fill all the fields.");
|
||||||
} else if (newPassword === newPassword2) {
|
}
|
||||||
|
|
||||||
|
if (newPassword !== newPassword2)
|
||||||
|
return toast.error("Passwords do not match.");
|
||||||
|
else if (newPassword.length < 8)
|
||||||
|
return toast.error("Passwords must be at least 8 characters.");
|
||||||
|
|
||||||
setSubmitLoader(true);
|
setSubmitLoader(true);
|
||||||
|
|
||||||
const load = toast.loading("Applying...");
|
const load = toast.loading("Applying...");
|
||||||
@@ -68,9 +74,7 @@ export default function ChangePassword({
|
|||||||
setUser({ ...user, newPassword: undefined });
|
setUser({ ...user, newPassword: undefined });
|
||||||
togglePasswordFormModal();
|
togglePasswordFormModal();
|
||||||
} else toast.error(response.data as string);
|
} else toast.error(response.data as string);
|
||||||
} else {
|
|
||||||
toast.error("Passwords do not match.");
|
|
||||||
}
|
|
||||||
setSubmitLoader(false);
|
setSubmitLoader(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -53,7 +53,10 @@ export default function Register() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (checkHasEmptyFields()) {
|
if (checkHasEmptyFields()) {
|
||||||
if (form.password === form.passwordConfirmation) {
|
if (form.password !== form.passwordConfirmation)
|
||||||
|
return toast.error("Passwords do not match.");
|
||||||
|
else if (form.password.length < 8)
|
||||||
|
return toast.error("Passwords must be at least 8 characters.");
|
||||||
const { passwordConfirmation, ...request } = form;
|
const { passwordConfirmation, ...request } = form;
|
||||||
|
|
||||||
setSubmitLoader(true);
|
setSubmitLoader(true);
|
||||||
@@ -80,9 +83,6 @@ export default function Register() {
|
|||||||
} else {
|
} else {
|
||||||
toast.error(data.response);
|
toast.error(data.response);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
toast.error("Passwords do not match.");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
toast.error("Please fill out all the fields.");
|
toast.error("Please fill out all the fields.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user