Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BA-2362 Add validations to reset change password #238

Merged
merged 2 commits into from
Mar 14, 2025

Conversation

Ronan-Fernandes
Copy link
Contributor

@Ronan-Fernandes Ronan-Fernandes commented Mar 12, 2025

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced password validation in both the expired password and reset password flows to enforce a minimum length and specific formatting requirements.
    • Users will now receive clearer error messages when a password doesn’t meet the updated complexity rules.
  • Tests

    • Updated test data for password variables to include more complex strings, improving the accuracy of password validation tests.
  • Chores

    • Updated package version numbers for @baseapp-frontend/authentication and @baseapp-frontend/components to reflect the latest changes.

Copy link

changeset-bot bot commented Mar 12, 2025

⚠️ No Changeset found

Latest commit: 699963b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

coderabbitai bot commented Mar 12, 2025

Walkthrough

The pull request updates password validation logic in two authentication modules. In both the expired password and reset password flows, the non-empty check for passwords has been replaced with a minimum length requirement and a regex check (using PASSWORD_REGEX). Additionally, the reset password module now imports PASSWORD_REGEX from the utility module. Test cases in both modules have also been updated to use a more complex password. No changes have been made to the exported or public entities.

Changes

File(s) Change Summary
.../useChangeExpiredPassword/constants.ts Updated newPassword validation: replaced z.string().nonempty with z.string().min(1).regex(PASSWORD_REGEX, { message: ZOD_MESSAGE.password }).
.../useResetPassword/constants.ts Updated newPassword validation similarly; modified import to include PASSWORD_REGEX from @baseapp-frontend/utils.
.../useChangeExpiredPassword/tests/useChangeExpiredPassword.test.tsx Updated password variable in tests from '123456' to '12345#Abcde' for better complexity.
.../useResetPassword/tests/useResetPassword.test.tsx Updated password constant in tests from '123456' to '12345#Abcde' for better complexity.
.../CHANGELOG.md Added version entry 4.1.9 noting patch changes for password validations in authentication processes.
.../package.json Updated version from 4.1.8 to 4.1.9 for @baseapp-frontend/authentication package.
.../CHANGELOG.md Added version entry 1.0.20 for @baseapp-frontend/components, updating dependency on @baseapp-frontend/authentication to version 4.1.9.
.../package.json Updated version from 1.0.19 to 1.0.20 for @baseapp-frontend/components package.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant A as Auth Module
    participant V as Validator

    U->>+A: Submit password change/reset request
    A->>+V: Validate password (min length, regex check)
    V-->>-A: Return validation result (pass/fail)
    A-->>-U: Respond with success or error
Loading

Possibly related PRs

  • BA-hotfix: current profile fixes #152: The changes in the main PR and the retrieved PR are related as both modify the validation schema for the newPassword field within the DEFAULT_VALIDATION_SCHEMA, albeit in different files.

Suggested labels

needs review

Suggested reviewers

  • anicioalexandre
  • priscilladeroode
  • deboracosilveira

Poem

In fields of code I gently hop,
Updating rules non-stop,
With regex magic in every byte,
Passwords secure day and night,
A rabbit’s cheer in each commit delight!
🐇💻

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

 ERR_PNPM_OPTIONAL_DEPS_REQUIRE_PROD_DEPS  Optional dependencies cannot be installed without production dependencies

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f7c1da and 699963b.

📒 Files selected for processing (8)
  • packages/authentication/CHANGELOG.md (1 hunks)
  • packages/authentication/modules/access/useChangeExpiredPassword/__tests__/useChangeExpiredPassword.test.tsx (1 hunks)
  • packages/authentication/modules/access/useChangeExpiredPassword/constants.ts (2 hunks)
  • packages/authentication/modules/access/useResetPassword/__tests__/useResetPassword.test.tsx (1 hunks)
  • packages/authentication/modules/access/useResetPassword/constants.ts (1 hunks)
  • packages/authentication/package.json (1 hunks)
  • packages/components/CHANGELOG.md (1 hunks)
  • packages/components/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/authentication/package.json
  • packages/authentication/CHANGELOG.md
  • packages/authentication/modules/access/useChangeExpiredPassword/tests/useChangeExpiredPassword.test.tsx
  • packages/authentication/modules/access/useResetPassword/tests/useResetPassword.test.tsx
  • packages/authentication/modules/access/useChangeExpiredPassword/constants.ts
  • packages/components/CHANGELOG.md
  • packages/components/package.json
  • packages/authentication/modules/access/useResetPassword/constants.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Build and Lint Packages
  • GitHub Check: Component Test Packages

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Ronan-Fernandes Ronan-Fernandes self-assigned this Mar 12, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/authentication/modules/access/useResetPassword/constants.ts (1)

9-12: Consider applying consistent validation to confirmNewPassword

While the validation for newPassword has been improved with regex pattern checking, confirmNewPassword still only uses nonempty validation. Although the refinement ensures both passwords match, applying consistent validation would make the code more maintainable.

    newPassword: z.string().min(1, ZOD_MESSAGE.required).regex(PASSWORD_REGEX, {
      message: ZOD_MESSAGE.password,
    }),
-   confirmNewPassword: z.string().nonempty(ZOD_MESSAGE.required),
+   confirmNewPassword: z.string().min(1, ZOD_MESSAGE.required).regex(PASSWORD_REGEX, {
+     message: ZOD_MESSAGE.password,
+   }),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b200009 and 29bc894.

📒 Files selected for processing (2)
  • packages/authentication/modules/access/useChangeExpiredPassword/constants.ts (1 hunks)
  • packages/authentication/modules/access/useResetPassword/constants.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
packages/authentication/modules/access/useResetPassword/constants.ts (2)

1-1: LGTM: Added PASSWORD_REGEX import

Good addition of the PASSWORD_REGEX import to support the enhanced password validation.


9-11: Improved password validation with regex pattern

The change strengthens security by adding regex validation to ensure password complexity, rather than just checking for non-emptiness.

packages/authentication/modules/access/useChangeExpiredPassword/constants.ts (2)

1-1: LGTM: Added PASSWORD_REGEX import

Good addition of the PASSWORD_REGEX import to support the enhanced password validation.


9-11: Improved currentPassword validation with regex pattern

The change strengthens security by adding regex validation to ensure password complexity, rather than just checking for non-emptiness.

@Ronan-Fernandes Ronan-Fernandes force-pushed the BA-2362-chnage-and-reset-password-validations branch 2 times, most recently from ed2f9a4 to 2e32d4c Compare March 13, 2025 21:22
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/authentication/CHANGELOG.md (1)

7-7: Changelog Description Clarity
The bullet point "- Add password validations to reset and change expired password" effectively communicates the change. Consider a minor rewording for clarity—perhaps "Add password validations for resetting and changing expired passwords"—to ensure it reads smoothly for both technical and non-technical stakeholders.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e32d4c and 9f7c1da.

📒 Files selected for processing (4)
  • packages/authentication/CHANGELOG.md (1 hunks)
  • packages/authentication/package.json (1 hunks)
  • packages/components/CHANGELOG.md (1 hunks)
  • packages/components/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • packages/components/package.json
  • packages/authentication/package.json
  • packages/components/CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Component Test Packages
🔇 Additional comments (1)
packages/authentication/CHANGELOG.md (1)

3-4: New Version Entry Added
The new version heading "## 4.1.9" clearly marks the update and aligns with the recent changes to password validations.

@Ronan-Fernandes Ronan-Fernandes force-pushed the BA-2362-chnage-and-reset-password-validations branch from 9f7c1da to 699963b Compare March 13, 2025 21:48
@Ronan-Fernandes Ronan-Fernandes merged commit 0da987c into master Mar 14, 2025
7 of 8 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