added min password length rule

This commit is contained in:
Daniel 2023-07-19 17:08:05 -04:00
parent ae71ce2020
commit 67989b7c05
2 changed files with 58 additions and 54 deletions

View File

@ -37,7 +37,13 @@ export default function ChangePassword({
const submit = async () => {
if (newPassword == "" || newPassword2 == "") {
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);
const load = toast.loading("Applying...");
@ -68,9 +74,7 @@ export default function ChangePassword({
setUser({ ...user, newPassword: undefined });
togglePasswordFormModal();
} else toast.error(response.data as string);
} else {
toast.error("Passwords do not match.");
}
setSubmitLoader(false);
};

View File

@ -53,7 +53,10 @@ export default function Register() {
};
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;
setSubmitLoader(true);
@ -80,9 +83,6 @@ export default function Register() {
} else {
toast.error(data.response);
}
} else {
toast.error("Passwords do not match.");
}
} else {
toast.error("Please fill out all the fields.");
}