feat(auth): password change #226
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a password change feature for authenticated users, adding a new password change form, API integration, validation schema, and UI navigation. While the title mentions "reset," only the password change functionality is implemented in this PR.
Changes:
- Added password change feature with form validation (minimum 8 characters, passwords must match, new password must differ from old)
- Integrated new API endpoint for password changes with error handling
- Added navigation menu item and dedicated page for password changes
- Modified backend logging to use warnings instead of errors for validation failures
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/features/password-change/schemas/change-password-schema.ts | Defines validation schema with password matching and difference checks |
| src/features/password-change/index.ts | Feature module exports for components, API, and schemas |
| src/features/password-change/components/change-password-form.tsx | React form component with error handling and toast notifications |
| src/features/password-change/api/change-password.ts | API integration function for password change endpoint |
| src/features/backend/utils/handle-response.ts | Modified to log validation errors as warnings instead of errors |
| src/components/presentation/navbar.tsx | Added "Change Password" menu item to user dropdown |
| src/app/(private)/change-password/page.tsx | New page component for password change functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4d293c6 to
720a346
Compare
720a346 to
e2e1cce
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@Konzum59 zrebasuj też brancha:) |
michalges
left a comment
There was a problem hiding this comment.
Jeśli będziesz robił "Zapomniałem hasła" w osobnej pr'ce to zrób issue od razu
| if (fieldName === "oldPassword" && typeof message === "string") { | ||
| form.setError("oldPassword", { | ||
| type: "server", | ||
| message, |
There was a problem hiding this comment.
To wywali surowy error message po angielsku, zamist tego lepiej toast z predefiniowanym, polskim napisem. Raczej można założyć, że jak pojawia się błąd z oldPassword to użytkownik podał niepoprawne hałso.
| control={form.control} | ||
| name="newPasswordConfirm" | ||
| render={({ field }) => ( | ||
| <PasswordInput |
There was a problem hiding this comment.
Może trochę czepliwie, ale imo tooltipy jak "Pokaż potwierdź nowe hasło" są trochę długie i niepotrzebne, wystarczyłoby "Pokaż hasło". Ale to bardziej jako propozycja
| .object({ | ||
| oldPassword: RequiredStringSchema, | ||
| newPassword: RequiredStringSchema.min(8, { | ||
| message: FORM_ERROR_MESSAGES.CHANGE_PASSWORD_MIN_LENGTH, | ||
| }) | ||
| .regex(/[A-Z]/, { | ||
| message: FORM_ERROR_MESSAGES.CHANGE_PASSWORD_REQUIRE_UPPER, | ||
| }) | ||
| .regex(/[a-z]/, { | ||
| message: FORM_ERROR_MESSAGES.CHANGE_PASSWORD_REQUIRE_LOWER, | ||
| }) | ||
| .regex(/[0-9]/, { | ||
| message: FORM_ERROR_MESSAGES.CHANGE_PASSWORD_REQUIRE_NUMBER, | ||
| }), | ||
| newPasswordConfirm: RequiredStringSchema, |
| let toastMessage: string | undefined; | ||
| try { | ||
| toastMessage = ( | ||
| getToastMessages.changePassword as { invalidOldPassword?: string } | ||
| ).invalidOldPassword; | ||
| } catch (error_) { | ||
| logger.error( | ||
| parseError(error_), | ||
| "ChangePasswordForm: failed to get invalidOldPassword message", | ||
| ); | ||
| } |
| import { ChangePasswordForm } from "@/features/password-change"; | ||
|
|
||
| export default function ChangePasswordPage() { | ||
| return ( | ||
| <div className="container mx-auto flex h-full flex-col items-center justify-center p-4 sm:p-8"> | ||
| <h1 className="mb-4 text-2xl font-semibold">Zmiana hasła</h1> | ||
| <ChangePasswordForm /> | ||
| </div> |
No description provided.