feat(auth): add confirm password field to registration form#33
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a “Confirm Password” field to the registration flow to prevent password typos during sign-up, aligning registration validation with the existing reset-password pattern.
Changes:
- Extended
registerSchemawithconfirmPasswordand a password match.refine(). - Updated the registration form UI/state to collect and submit
confirmPassword. - Added/updated unit + E2E test coverage for confirm-password behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/validations/auth.ts |
Adds confirmPassword to registration validation and enforces password match via .refine(). |
components/auth/register-form.tsx |
Adds confirm-password input and includes it in the server action payload. |
lib/validations/auth.test.ts |
New unit tests covering valid/mismatch/missing confirm-password cases. |
e2e/auth/register.spec.ts |
Updates registration E2E coverage to fill confirm password and adds mismatch scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export const registerSchema = z.object({ | ||
| email: emailSchema, | ||
| password: passwordSchema, | ||
| confirmPassword: z.string(), | ||
| displayName: displayNameSchema.optional(), | ||
| }).refine((data) => data.password === data.confirmPassword, { | ||
| message: "Passwords do not match", | ||
| path: ["confirmPassword"], | ||
| }); |
There was a problem hiding this comment.
confirmPassword uses z.string() without a .min(1, ...), so when the field is missing/empty the returned Zod message will be the generic "Required" (and this is surfaced to users via parsed.error.issues[0]?.message). Consider adding an explicit required message (e.g., .min(1, "Confirm password is required")) to keep error messaging consistent with emailSchema / displayNameSchema.
| await expect(page.getByLabel("Password", { exact: true })).toBeVisible(); | ||
| await expect(page.getByLabel("Confirm Password")).toBeVisible(); |
There was a problem hiding this comment.
Other E2E specs use the shared registerUser helper (e2e/fixtures/test-helpers.ts) which still does getByLabel("Password") and does not fill the now-required Confirm Password field. With two password-labeled inputs, this will likely become ambiguous and the submission will be blocked by HTML required validation. Update the helper (and any other E2E tests) to use getByLabel("Password", { exact: true }) and fill Confirm Password so the full E2E suite continues to pass.
|
Found 18 test failures on Blacksmith runners: Failures
|
Require users to repeat their password during sign-up to prevent typos.
lib/validations/auth.ts): AddedconfirmPasswordtoregisterSchemawith.refine()match check, consistent with existingresetPasswordSchemapatterncomponents/auth/register-form.tsx): Added "Confirm Password" input field and statelib/validations/auth.test.ts): Covers matching, mismatched, and missing confirm password casese2e/auth/register.spec.ts): Updated all tests to fill confirm password; added password mismatch test; uses{ exact: true }on Password label to disambiguate from Confirm Password💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.