Skip to content

Commit 0408098

Browse files
luizhf42gustavosbarreto
authored andcommitted
fix(ui): fix confirm password behavior in SignUp
1 parent 9715a79 commit 0408098

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

ui/src/views/SignUp.vue

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
data-test="password-text"
6464
:type="showPassword ? 'text' : 'password'"
6565
@click:append-inner="showPassword = !showPassword"
66+
@update:model-value="handlePasswordChange"
6667
/>
6768

6869
<v-text-field
@@ -77,6 +78,7 @@
7778
data-test="password-confirm-text"
7879
:type="showConfirmPassword ? 'text' : 'password'"
7980
@click:append-inner="showConfirmPassword = !showConfirmPassword"
81+
@update:model-value="handlePasswordChange"
8082
/>
8183
</v-container>
8284

@@ -217,27 +219,29 @@ const {
217219
value: password,
218220
errorMessage: passwordError,
219221
setErrors: setPasswordError,
220-
} = useField<string>("password", yup.string().required().min(5).max(32), {
222+
} = useField<string>("password", yup.string().required("This field is required").min(5).max(32), {
221223
initialValue: "",
222224
});
223225
224226
const {
225227
value: passwordConfirm,
226228
errorMessage: passwordConfirmError,
227-
} = useField<string>("passwordConfirm", yup.string().required()
229+
setErrors: setPasswordConfirmError,
230+
} = useField<string>("passwordConfirm", yup.string().required("This field is required")
228231
.test("passwords-match", "Passwords do not match", (value) => password.value === value), {
229232
initialValue: "",
230233
});
231234
232-
onMounted(() => {
233-
const emailQuery = route.query.email as string;
234-
sigValue.value = route.query.sig as string;
235+
const handlePasswordChange = () => {
236+
if (!passwordConfirm.value || !password.value) return;
235237
236-
if (emailQuery && sigValue.value) {
237-
email.value = emailQuery;
238-
isEmailLocked.value = true;
238+
if (password.value !== passwordConfirm.value) {
239+
setPasswordConfirmError("Passwords do not match");
240+
return;
239241
}
240-
});
242+
243+
setPasswordConfirmError("");
244+
};
241245
242246
const hasErrors = () => !!(
243247
nameError.value
@@ -286,4 +290,13 @@ const createAccount = async () => {
286290
}
287291
};
288292
293+
onMounted(() => {
294+
const emailQuery = route.query.email as string;
295+
sigValue.value = route.query.sig as string;
296+
297+
if (emailQuery && sigValue.value) {
298+
email.value = emailQuery;
299+
isEmailLocked.value = true;
300+
}
301+
});
289302
</script>

0 commit comments

Comments
 (0)