-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Conversation
@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. |
WalkthroughThe recent update to the Changes
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
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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'
There was a problem hiding this 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 insubmitHandler
.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
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"); |
There was a problem hiding this comment.
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.
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; | ||
} | ||
} |
There was a problem hiding this comment.
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.
const isGenuineEmail = await checkEmail(data.email); | ||
if (!isGenuineEmail) return; |
There was a problem hiding this comment.
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
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 |
@pankaj-bind if i didn't get changes in this pr by sunday, then I will reject this |
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