|
63 | 63 | data-test="password-text" |
64 | 64 | :type="showPassword ? 'text' : 'password'" |
65 | 65 | @click:append-inner="showPassword = !showPassword" |
| 66 | + @update:model-value="handlePasswordChange" |
66 | 67 | /> |
67 | 68 |
|
68 | 69 | <v-text-field |
|
77 | 78 | data-test="password-confirm-text" |
78 | 79 | :type="showConfirmPassword ? 'text' : 'password'" |
79 | 80 | @click:append-inner="showConfirmPassword = !showConfirmPassword" |
| 81 | + @update:model-value="handlePasswordChange" |
80 | 82 | /> |
81 | 83 | </v-container> |
82 | 84 |
|
@@ -217,27 +219,29 @@ const { |
217 | 219 | value: password, |
218 | 220 | errorMessage: passwordError, |
219 | 221 | 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), { |
221 | 223 | initialValue: "", |
222 | 224 | }); |
223 | 225 |
|
224 | 226 | const { |
225 | 227 | value: passwordConfirm, |
226 | 228 | errorMessage: passwordConfirmError, |
227 | | -} = useField<string>("passwordConfirm", yup.string().required() |
| 229 | + setErrors: setPasswordConfirmError, |
| 230 | +} = useField<string>("passwordConfirm", yup.string().required("This field is required") |
228 | 231 | .test("passwords-match", "Passwords do not match", (value) => password.value === value), { |
229 | 232 | initialValue: "", |
230 | 233 | }); |
231 | 234 |
|
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; |
235 | 237 |
|
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; |
239 | 241 | } |
240 | | -}); |
| 242 | +
|
| 243 | + setPasswordConfirmError(""); |
| 244 | +}; |
241 | 245 |
|
242 | 246 | const hasErrors = () => !!( |
243 | 247 | nameError.value |
@@ -286,4 +290,13 @@ const createAccount = async () => { |
286 | 290 | } |
287 | 291 | }; |
288 | 292 |
|
| 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 | +}); |
289 | 302 | </script> |
0 commit comments