-
-
Notifications
You must be signed in to change notification settings - Fork 99
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: User creation on register #272
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe recent updates primarily focus on streamlining user management processes related to registration, password updates, and email verification. These changes aim to enhance validation, error handling, and database interactions for improved reliability and user experience. Navigation adjustments and more robust response checks have been implemented to refine the functionality of authentication components. Changes
Assessment against linked issues
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (4)
Files skipped from review due to trivial changes (1)
Files skipped from review as they are similar to previous changes (3)
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, @Sanchitbajaj02! 🎉 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: 7
if (!email || email == "") { | ||
throw new Error("Email not provided"); |
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.
Ensure robust email validation by checking for whitespace-only strings.
- if (!email || email == "") {
+ if (!email.trim()) {
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.
if (!email || email == "") { | |
throw new Error("Email not provided"); | |
if (!email.trim()) { | |
throw new Error("Email not provided"); |
if (!response) { | ||
throw new Error("Err in sending email"); | ||
} |
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.
Ensure that the error message is descriptive and user-friendly.
- throw new Error("Err in sending email");
+ throw new Error("Error occurred while sending the email. Please try again.");
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.
if (!response) { | |
throw new Error("Err in sending email"); | |
} | |
if (!response) { | |
throw new Error("Error occurred while sending the email. Please try again."); | |
} |
if (!resp) { | ||
throw new Error("Err in changing password"); | ||
} |
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.
Ensure that the error message is clear and actionable for the user.
- throw new Error("Err in changing password");
+ throw new Error("Failed to update password. Please ensure your details are correct and try again.");
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.
if (!resp) { | |
throw new Error("Err in changing password"); | |
} | |
if (!resp) { | |
throw new Error("Failed to update password. Please ensure your details are correct and try again."); | |
} |
src/backend/auth.api.ts
Outdated
if (!currentUser) { | ||
throw new Error("Current user might be corrupted"); | ||
} | ||
|
||
const result = db.updateDocument(palettegramDB, usersCollection, currentUser.documents[0].$id, { | ||
isVerified: true, | ||
}); | ||
|
||
if (!result) { | ||
throw new Error("Error in verifying user"); | ||
} |
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.
Validate that the error handling is robust and the error messages are informative.
- throw new Error("Current user might be corrupted");
+ throw new Error("Failed to retrieve current user data. Please verify the user ID and database status.");
- throw new Error("Error in verifying user");
+ throw new Error("Failed to update user verification status. Please check the database operation.");
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.
if (!currentUser) { | |
throw new Error("Current user might be corrupted"); | |
} | |
const result = db.updateDocument(palettegramDB, usersCollection, currentUser.documents[0].$id, { | |
isVerified: true, | |
}); | |
if (!result) { | |
throw new Error("Error in verifying user"); | |
} | |
if (!currentUser) { | |
throw new Error("Failed to retrieve current user data. Please verify the user ID and database status."); | |
} | |
const result = db.updateDocument(palettegramDB, usersCollection, currentUser.documents[0].$id, { | |
isVerified: true, | |
}); | |
if (!result) { | |
throw new Error("Failed to update user verification status. Please check the database operation."); | |
} |
src/backend/auth.api.ts
Outdated
|
||
// const getOldUserDetails = await db.listDocuments(palettegramDB, usersCollection, [ | ||
// Query.equal("email", userEmail), | ||
// ]); | ||
|
||
// if (!getOldUserDetails) { | ||
// throw new Error("user does not exist"); | ||
// } | ||
|
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.
Consider removing or implementing the commented-out code to maintain code cleanliness.
Consider implementing the commented-out functionality or removing it if it's not planned for future use.
userData.USER_ID === "" || | ||
userData.SECRET === " " | ||
) { | ||
if (password === "" || confirmpassword === "" || USER_ID === "" || SECRET === " ") { |
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.
Enhance the validation check to include all fields comprehensively.
- if (password === "" || confirmpassword === "" || USER_ID === "" || SECRET === " ") {
+ if (!password.trim() || !confirmpassword.trim() || !USER_ID.trim() || !SECRET.trim()) {
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.
if (password === "" || confirmpassword === "" || USER_ID === "" || SECRET === " ") { | |
if (!password.trim() || !confirmpassword.trim() || !USER_ID.trim() || !SECRET.trim()) { |
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: 7
Out of diff range and nitpick comments (1)
src/components/pages/auth/verification/index.tsx (1)
50-50
: Consider adding dependency array comments inuseEffect
for clarity.Adding comments explaining why
secret
andaccountId
are included in the dependency array ofuseEffect
can improve code maintainability by making the intentions behind these dependencies clear.
@@ -41,6 +41,10 @@ const getUserFieldByAccountId = async (userId: string) => { | |||
|
|||
const saveImage = async (image: File) => { | |||
try { | |||
if (!image) { |
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.
Ensure proper error handling in saveImage
.
- throw new Error("error aa rha hai");
+ throw new Error("Image upload failed due to an unspecified error. Please check the input and storage permissions.");
The error message should be more descriptive and professional to aid in debugging and user communication.
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.
if (!image) { | |
if (!image) { | |
throw new Error("Image upload failed due to an unspecified error. Please check the input and storage permissions."); |
if (resp) { | ||
return resp; | ||
if (!result02) { | ||
throw new Error("Error aa rha hai bannerURL mai"); |
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.
Improve error message consistency.
- throw new Error("Error aa rha hai bannerURL mai");
+ throw new Error("Failed to update the banner URL in the database. Please check the document ID and database status.");
The error message should be consistent and informative, providing clear information about what went wrong and where.
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.
throw new Error("Error aa rha hai bannerURL mai"); | |
throw new Error("Failed to update the banner URL in the database. Please check the document ID and database status."); |
|
||
const handleFileUpload = async (event: any) => { | ||
const fsize = Math.round(event.target.files[0].size / imageSizeLimit); | ||
const fsize: number = Math.round(event.target.files[0].size / imageSizeLimit); |
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.
Validate image size more effectively.
- toastify("Image size cannot be more that 1MB", "error");
+ toastify("Image size cannot be more than 1MB", "error");
Correct the typo in the toast message to enhance the user experience and professionalism.
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.
const fsize: number = Math.round(event.target.files[0].size / imageSizeLimit); | |
const fsize: number = Math.round(event.target.files[0].size / imageSizeLimit); |
const fileObject = await saveImage(image?.file!); | ||
if (!fileObject) throw new Error("Failed to load image, retry!"); | ||
if (!fileObject) { | ||
throw new Error("Failed to load image, retry!"); |
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.
Improve error handling for image upload failures.
- throw new Error("Failed to load image, retry!");
+ throw new Error("Failed to upload image. Please check the network connection and try again.");
Provide a more detailed error message that guides the user on how to resolve the issue.
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.
throw new Error("Failed to load image, retry!"); | |
throw new Error("Failed to upload image. Please check the network connection and try again."); |
const authResp = await account.updatePrefs({ | ||
username: username, | ||
}); | ||
|
||
const dbData = await saveDataToDatabase(authResp); | ||
|
||
if (!dbData) { | ||
throw new Error("User data can't be saved properly"); | ||
} |
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.
Improve error handling in register
.
- throw new Error("User data can't be saved properly");
+ throw new Error("Failed to save user data to the database. Please check the database connection and data integrity.");
Enhance the error message to provide more context and help in debugging.
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.
const authResp = await account.updatePrefs({ | |
username: username, | |
}); | |
const dbData = await saveDataToDatabase(authResp); | |
if (!dbData) { | |
throw new Error("User data can't be saved properly"); | |
} | |
const authResp = await account.updatePrefs({ | |
username: username, | |
}); | |
const dbData = await saveDataToDatabase(authResp); | |
if (!dbData) { | |
throw new Error("Failed to save user data to the database. Please check the database connection and data integrity."); | |
} |
}); | ||
|
||
if (!result) { | ||
throw new Error("Error in verifying user"); |
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.
Improve error handling in user verification.
- throw new Error("Error in verifying user");
+ throw new Error("Failed to update user verification status. Please check the database operation.");
The error message should be more informative and specific to aid in troubleshooting.
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.
throw new Error("Error in verifying user"); | |
throw new Error("Failed to update user verification status. Please check the database operation."); |
@@ -331,17 +331,17 @@ export default function SinglePost({ | |||
<div className="flex justify-around"> | |||
<article | |||
onClick={() => onLikeClick(singlePost)} | |||
className="flex flex-row gap-3 items-center transition ease-in-out duration-200 hover:cursor-pointer" | |||
className="flex flex-row gap-3 items-center transition ease-in-out duration-200 hover:cursor-pointer hover:text-primary dark:hover:text-primary text-secondary-light dark:text-white" |
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.
Ensure consistent UI/UX in post interactions.
- className="flex flex-row gap-3 items-center transition ease-in-out duration-200 hover:cursor-pointer hover:text-primary dark:hover:text-primary text-secondary-light dark:text-white"
+ className="flex flex-row gap-3 items-center transition ease-in-out duration-200 cursor-pointer hover:text-primary dark:hover:text-primary text-secondary-light dark:text-white"
Add cursor:pointer
to the default class list to ensure that the cursor indicates a clickable item consistently across all states.
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.
className="flex flex-row gap-3 items-center transition ease-in-out duration-200 hover:cursor-pointer hover:text-primary dark:hover:text-primary text-secondary-light dark:text-white" | |
className="flex flex-row gap-3 items-center transition ease-in-out duration-200 cursor-pointer hover:text-primary dark:hover:text-primary text-secondary-light dark:text-white" |
Related Issue
fixes #267
Description
changes pending for state and store handling
Summary by CodeRabbit
New Features
Bug Fixes
Style
Documentation
Chores
Refactor
next.config.js
to optimize the build process by ignoring ESLint checks during builds.