Skip to content

Fix: changepassword validation. Closes #951#963

Merged
regulartim merged 4 commits intoGreedyBear-Project:developfrom
UsamaElareeny:fix-changepassword-validation
Mar 9, 2026
Merged

Fix: changepassword validation. Closes #951#963
regulartim merged 4 commits intoGreedyBear-Project:developfrom
UsamaElareeny:fix-changepassword-validation

Conversation

@UsamaElareeny
Copy link
Copy Markdown
Contributor

@UsamaElareeny UsamaElareeny commented Mar 5, 2026

Description

  1. Ensured that change password's validation is based on validator.tsx and add a new validation OldNewPasswordValidator to check whether the old and new password match or empty.
  2. Created a custom hook change password toggle and used it in all different forms.
  3. Changed the errors from toast-based into inline-based errors for better user experience.
  4. Added tests for the custom hook component and added/edited some tests in change password.

Related issues

Closes #951

Type of change

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Chore (refactoring, dependency updates, CI/CD changes, code cleanup, docs-only changes).

Checklist

Please complete this checklist carefully. It helps guide your contribution and lets maintainers verify that all requirements are met.

Formalities

  • I have read and understood the rules about how to Contribute to this project.
  • I chose an appropriate title for the pull request in the form: <feature name>. Closes #999
  • My branch is based on develop.
  • The pull request is for the branch develop.
  • I have reviewed and verified any LLM-generated code included in this PR.

Docs and tests

  • I documented my code changes with docstrings and/or comments.
  • I have checked if my changes affect user-facing behavior that is described in the docs. If so, I also created a pull request in the docs repository.
  • Linter (Ruff) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.
  • I have added tests for the feature/bug I solved.
  • All the tests gave 0 errors.

Copilot AI review requested due to automatic review settings March 5, 2026 11:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns the Change Password form with the shared auth validators, adds a reusable show-password toggle hook/component across auth-related forms, and replaces toast-based validation errors with inline form errors (closing #951).

Changes:

  • Refactors ChangePassword validation to use PasswordValidator, ComparePassword, and new OldNewPasswordValidator, and enables validateOnMount.
  • Introduces usePasswordVisibility + ShowPasswordToggle and adopts them in Login/Register/ResetPassword/ChangePassword.
  • Updates/adds frontend tests to cover the new toggle behavior and inline validation errors.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
frontend/src/components/me/changepassword/ChangePassword.jsx Switches to shared validators, adds inline errors and show-password toggle support.
frontend/src/components/auth/utils/validator.jsx Adds OldNewPasswordValidator for “old vs new password” comparison.
frontend/src/components/common/ShowPasswordToggle.jsx Adds reusable show-password toggle component and visibility hook.
frontend/src/components/auth/Login.jsx Replaces local checkbox state with shared password visibility hook/component.
frontend/src/components/auth/Register.jsx Replaces local checkbox state with shared password visibility hook/component.
frontend/src/components/auth/ResetPassword.jsx Replaces local checkbox state with shared password visibility hook/component.
frontend/tests/components/me/changepassword/ChangePassword.test.jsx Updates tests for inline errors and show-password toggle behavior in ChangePassword.
frontend/tests/components/common/ShowPasswordToggle.test.jsx Adds unit tests for the new toggle component and visibility hook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@UsamaElareeny
Copy link
Copy Markdown
Contributor Author

Hi @regulartim , Please take a look into this when you have time and tell me if there's anything I need to do.

Copy link
Copy Markdown
Collaborator

@regulartim regulartim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you! :)

@regulartim regulartim merged commit 4f65b03 into GreedyBear-Project:develop Mar 9, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants