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

feat: signup password hint #959

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

anikdhabal
Copy link
Contributor

@anikdhabal anikdhabal commented Feb 23, 2024

fixes #954

14b819e39cfe404188af025df75cd6d9.mp4

Summary by CodeRabbit

  • New Features

    • Introduced a "Hinted Password" input component with interactive password strength validation hints.
  • Enhancements

    • Updated password fields in sign-up forms to provide real-time feedback on password strength and criteria compliance.
  • Refactor

    • Standardized password schema naming and replaced obsolete components with new hinted password input components.

Copy link
Contributor

coderabbitai bot commented Feb 23, 2024

Walkthrough

The core changes in this update enhance the signup form experience by integrating password hints. Components have transitioned from using PasswordInput and ZPasswordSchema to HintedPasswordInput and ZHintedPasswordSchema. This upgrade ensures that users receive immediate feedback on password strength and requirements, fostering a more intuitive and secure signup process.

Changes

Files Change Summary
apps/web/src/components/forms/signup.tsx, apps/web/src/components/forms/v2/signup.tsx, apps/web/src/components/forms/password.tsx Updated to use ZHintedPasswordSchema and HintedPasswordInput, replacing previous imports and usage.
packages/trpc/server/auth-router/schema.ts Introduced ZHintedPasswordSchema with specific password criteria.
packages/ui/primitives/password-input.tsx Reorganized import statements for better organization.
packages/ui/primitives/hinted-password-input.tsx Added new HintedPasswordInput component with dynamic hints.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant SignUpForm as SignUpForm
    participant HintedPasswordInput as HintedPasswordInput
    participant Validator as Validator

    User->>SignUpForm: Access Signup Form
    SignUpForm->>HintedPasswordInput: Focus on Password Input
    HintedPasswordInput->>HintedPasswordInput: Display Password Hints
    User->>HintedPasswordInput: Enter Password
    HintedPasswordInput->>Validator: Validate Password
    Validator-->>HintedPasswordInput: Return Validation Results
    HintedPasswordInput-->>User: Update Password Hints
Loading

Assessment against linked issues

Objective Addressed Explanation
Show password hints in the signup password field (#954)

Poem

In forms where hints and feedback meet,
Our signup thrives, a user's treat.
With whispered hints and checks so neat,
Passwords now are safe and sweet.
A change so simple, yet so grand,
Making signups smooth and planned.
Hop along, code bunnies, with delight,
For passwords now are sure and bright! 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Copy link

vercel bot commented Feb 23, 2024

@anikdhabal is attempting to deploy a commit to the Documenso Team Team on Vercel.

A member of the Team first needs to authorize it.

@prajwalkulkarni
Copy link
Contributor

As per the React docs, it is advised to use useEffect to synchronize the component with an external system. Since no synchronizations are being done here, I believe the code in the effect handler can be extracted out and conditionally executed in the component, i.e., the validation can run whenever the input is changed and the user has focused on the input field. This way we can get rid of the useEffect. What do you think?

@anikdhabal anikdhabal changed the title feat: password hint feat: signup password hint Feb 24, 2024
@adithyaakrishna
Copy link
Contributor

@anikdhabal The in-built schema validation is giving errors due to the changes to password-input.tsx file. I've also attached the screenshots below for reference

Sign up:

Screenshot 2024-03-01 at 13 35 29

Sign in:

Screenshot 2024-03-01 at 13 34 17

@github-actions github-actions bot added the apps: web Issues related to the webapp label Mar 6, 2024
@anikdhabal
Copy link
Contributor Author

@anikdhabal The in-built schema validation is giving errors due to the changes to password-input.tsx file. I've also attached the screenshots below for reference

Sign up:

Screenshot 2024-03-01 at 13 35 29 **Sign in:** Screenshot 2024-03-01 at 13 34 17

Hey @adithyaakrishna thanks for the review. I've fixed it.

@dguyen
Copy link
Collaborator

dguyen commented Apr 4, 2024

Some feedback on the design, I haven't looked at the code yet:

  • This doesn't really work with many resolutions since it'll overflow out of the screen, especially with the new sign up form design
  • The arrow symbol should probably match the color of the tooltip on light theme

Maybe have a look at the PopOver primitive?

@anikdhabal
Copy link
Contributor Author

Some feedback on the design, I haven't looked at the code yet:

  • This doesn't really work with many resolutions since it'll overflow out of the screen, especially with the new sign up form design
  • The arrow symbol should probably match the color of the tooltip on light theme

Maybe have a look at the PopOver primitive?

Thank you for the review. We can move the tooltip to the left side from the right as it is overflows in the new design. Additionally, I will fix the arrow symbol.

Copy link

vercel bot commented May 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
stg-docs ❌ Failed (Inspect) Jun 18, 2024 3:29pm

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e519739 and d261844.

Files selected for processing (3)
  • apps/web/src/components/forms/signup.tsx (4 hunks)
  • apps/web/src/components/forms/v2/signup.tsx (4 hunks)
  • packages/trpc/server/auth-router/schema.ts (1 hunks)
Additional context used
Biome
packages/trpc/server/auth-router/schema.ts

[error] 13-13: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 14-14: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 15-15: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 16-16: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 24-24: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 25-25: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 26-26: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 27-27: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

Additional comments not posted (2)
apps/web/src/components/forms/signup.tsx (1)

14-14: Changes related to the password input handling align well with the PR objectives.

Also applies to: 25-25, 36-36, 185-185

apps/web/src/components/forms/v2/signup.tsx (1)

23-23: Changes ensure consistency across different versions of the signup form and align with the PR objectives.

Also applies to: 34-34, 50-50, 314-314

Comment on lines +11 to +20
export const ZHintedPasswordSchema = z
.string()
.regex(new RegExp('.*[A-Z].*'))
.regex(new RegExp('.*[a-z].*'))
.regex(new RegExp('.*\\d.*'))
.regex(new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), {
message: 'One special character is required',
})
.min(8)
.max(72);
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace RegExp constructor with regex literals for better performance and readability.

-  .regex(new RegExp('.*[A-Z].*'))
-  .regex(new RegExp('.*[a-z].*'))
-  .regex(new RegExp('.*\\d.*'))
-  .regex(new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), {
+  .regex(/.*[A-Z].*/)
+  .regex(/.*[a-z].*/)
+  .regex(/.*\\d.*/)
+  .regex(/.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*/, {
     message: 'One special character is required',
   })
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const ZHintedPasswordSchema = z
.string()
.regex(new RegExp('.*[A-Z].*'))
.regex(new RegExp('.*[a-z].*'))
.regex(new RegExp('.*\\d.*'))
.regex(new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), {
message: 'One special character is required',
})
.min(8)
.max(72);
export const ZHintedPasswordSchema = z
.string()
.regex(/.*[A-Z].*/)
.regex(/.*[a-z].*/)
.regex(/.*\\d.*/)
.regex(/.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*/, {
message: 'One special character is required',
})
.min(8)
.max(72);
Tools
Biome

[error] 13-13: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 14-14: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 15-15: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 16-16: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

@anikdhabal
Copy link
Contributor Author

anikdhabal commented Jul 26, 2024

@dguyen @Mythie any updates on this?

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d261844 and 1b6d07c.

Files selected for processing (1)
  • apps/web/src/components/forms/v2/signup.tsx (4 hunks)
Additional comments not posted (4)
apps/web/src/components/forms/v2/signup.tsx (4)

23-23: Import of ZHintedPasswordSchema looks good.

The import statement for ZHintedPasswordSchema is correctly added. Ensure that the schema is used properly in the form validation.


34-34: Import of HintedPasswordInput looks good.

The import statement for HintedPasswordInput is correctly added. Ensure that the component is used properly in the form rendering.


50-50: Usage of ZHintedPasswordSchema looks good.

The ZHintedPasswordSchema is correctly used in the schema definition. Ensure that the validation logic is appropriate and covers all necessary password requirements.


314-314: Usage of HintedPasswordInput looks good.

The HintedPasswordInput is correctly used in the form rendering. Ensure that the rendering logic is appropriate and the hint functionality works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apps: web Issues related to the webapp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: signup password hint
4 participants