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: Filter genuine email added #351

Closed
wants to merge 1 commit into from

Conversation

pankaj-bind
Copy link

@pankaj-bind pankaj-bind commented Jun 2, 2024

Related Issue

fixes #306

Description

now when user clicks on register now, if the email is disposable then alerts disposable email and do not create account, and if email is genuine then it will proceed.

Summary by CodeRabbit

  • New Features
    • Added email validation to the registration form to ensure email authenticity before submission.
  • Bug Fixes
    • Corrected a typo in the form submission handler function name.
  • Enhancements
    • Improved the clarity of error messages during registration.

Copy link

vercel bot commented Jun 2, 2024

@pankaj-bind is attempting to deploy a commit to the Sanchit Bajaj's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jun 2, 2024

Walkthrough

The recent update to the RegisterComponent in index.tsx includes renaming the submitHander function to submitHandler and introducing a new checkEmail function to validate the email's authenticity before form submission. Additionally, error messages have been refined for better clarity.

Changes

File Summary of Changes
src/components/pages/auth/register/index.tsx Renamed submitHander to submitHandler; added checkEmail for email validation; updated error messages

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant RegisterComponent
    participant EmailService

    User->>RegisterComponent: Submit Registration Form
    RegisterComponent->>RegisterComponent: validate form fields
    RegisterComponent->>EmailService: checkEmail(email)
    EmailService-->>RegisterComponent: email validation result
    alt email valid
        RegisterComponent->>RegisterComponent: submitHandler(event)
        RegisterComponent-->>User: Registration Successful
    else email invalid
        RegisterComponent-->>User: Display Error Message
    end
Loading

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 Configration 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.

@github-actions github-actions bot added wait for reviewers gssoc GSSOC'24 Required Label labels Jun 2, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Great job, @pankaj-bind! 🎉 Thank you for submitting your pull request. Your contribution is valuable and we appreciate your efforts to improve our project. Keep being the part of the community!

'We will promptly review your changes and offer feedback. Keep up the excellent work!
Kindly remember to check our Contributing Guidelines'

@github-actions github-actions bot added the title needs formatting Title of issue or pull request does not match the guidelines label Jun 2, 2024
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: 3

Outside diff range and nitpick comments (1)
src/components/pages/auth/register/index.tsx (1)

Line range hint 63-89: Ensure consistent error handling and validation in submitHandler.

The submitHandler function has multiple points where exceptions are thrown for various validation failures. It's crucial to ensure that these errors are handled consistently and provide clear feedback to the user. Consider consolidating error messages and handling them in a single place to improve maintainability and user experience.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 49276ec and a5c7418.

Files selected for processing (1)
  • src/components/pages/auth/register/index.tsx (4 hunks)
Additional context used
Biome
src/components/pages/auth/register/index.tsx

[error] 114-114: Unexpected any. Specify a different type.


[error] 15-16: All these imports are only used as types.


[error] 17-18: All these imports are only used as types.

Additional comments not posted (1)
src/components/pages/auth/register/index.tsx (1)

157-157: Validate form submission method.

The form uses a POST method which is typical for data submission. However, ensure that the server-side implementation correctly handles this method to prevent issues.

@@ -54,7 +74,7 @@ export default function RegisterComponent() {
}

if (data.password !== data.confirmpassword) {
throw new Error("Password and Confirm Password does not match");
throw new Error("Password and Confirm Password do not match");
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor error messages for better clarity and consistency.

The error messages thrown in the submitHandler function could be more descriptive and consistent. This will help users understand exactly what they need to correct in their input.

- throw new Error("Password and Confirm Password do not match");
+ throw new Error("The passwords entered do not match. Please try again.");

- throw new Error("Password format not matched");
+ throw new Error("Password format is incorrect. Ensure it includes a character, a number, and a special character.");

Also applies to: 89-89

Committable suggestion was skipped due low confidence.

Comment on lines +46 to +61
async function checkEmail(email: string): Promise<boolean> {
try {
const response = await fetch(`https://disposable.debounce.io/?email=${email}`);
const data = await response.json();
if (data.disposable === "true") {
alert("Disposable email");
return false;
}
alert("Email is genuine");
return true;
} catch (error) {
console.error('Error:', error);
alert("An error occurred while checking the email.");
return false;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement error handling improvements in checkEmail.

The checkEmail function currently uses a generic alert for error handling which might not be the best user experience. Consider using a more user-friendly approach, such as displaying the error message within the UI instead of using browser alerts. Additionally, the error logging could be more descriptive.

- console.error('Error:', error);
+ console.error('checkEmail error:', error);

Committable suggestion was skipped due low confidence.

Comment on lines +66 to +67
const isGenuineEmail = await checkEmail(data.email);
if (!isGenuineEmail) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The submitHandler function in src/components/pages/auth/register/index.tsx does not provide any user feedback when the email is not genuine. It simply returns without any notification to the user.

  • Lines 66-67: const isGenuineEmail = await checkEmail(data.email); if (!isGenuineEmail) return;

Consider adding user feedback to inform the user why the registration process is halted.

Analysis chain

Verify the logic flow in submitHandler.

The current implementation returns immediately if the email is not genuine, without providing any feedback to the user. It might be beneficial to inform the user why the registration process is halted.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the user feedback mechanism when an email is not genuine.
# Test: Search for user feedback related code. Expect: User feedback implementation when email is not genuine.
rg --type typescript $'if \(!isGenuineEmail\) return;'

Length of output: 90



Script:

#!/bin/bash
# Description: Verify the user feedback mechanism when an email is not genuine.
# Test: Search for user feedback related code. Expect: User feedback implementation when email is not genuine.
rg --type ts $'if (!isGenuineEmail) return;'

Length of output: 45



Script:

#!/bin/bash
# Description: Locate the `submitHandler` function and inspect its implementation for user feedback mechanisms.
# Step 1: Locate the `submitHandler` function in the codebase.
ast-grep --lang typescript --pattern 'function submitHandler($_) { $$$ }' --json

Length of output: 85



Script:

#!/bin/bash
# Description: Search for the `submitHandler` function definition and its usage in the codebase.
# Step 1: Search for the `submitHandler` function definition.
rg 'function submitHandler' --type ts

# Step 2: Search for the `submitHandler` function usage.
rg 'submitHandler' --type ts

Length of output: 407



Script:

#!/bin/bash
# Description: Extract the implementation of the `submitHandler` function from `src/components/pages/auth/register/index.tsx`.
# Step 1: Extract the `submitHandler` function implementation.
ast-grep --lang typescript --pattern 'async function submitHandler($_) { $$$ }' src/components/pages/auth/register/index.tsx

Length of output: 4656

@Sanchitbajaj02
Copy link
Owner

Hi @pankaj-bind, can you provide the emails on which you have tested this debounce Api. I have used some of my emails as well as some random emails, but it is returning disposable: false in every case

@Sanchitbajaj02 Sanchitbajaj02 changed the title Filter genuine email added feat: Filter genuine email added Jun 3, 2024
@github-actions github-actions bot removed the title needs formatting Title of issue or pull request does not match the guidelines label Jun 3, 2024
@Sanchitbajaj02 Sanchitbajaj02 added 🏆 good first issue Good for newcomers ⭐ enhancement Feature enhancement MEDIUM Difficulty Level: Medium level2 25 points and removed wait for reviewers labels Jun 3, 2024
@Sanchitbajaj02
Copy link
Owner

@pankaj-bind if i didn't get changes in this pr by sunday, then I will reject this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐ enhancement Feature enhancement 🏆 good first issue Good for newcomers gssoc GSSOC'24 Required Label level2 25 points MEDIUM Difficulty Level: Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: Filter genuine email
2 participants