-
Notifications
You must be signed in to change notification settings - Fork 299
node_auth #230
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
base: master
Are you sure you want to change the base?
node_auth #230
Conversation
mateacademy-ai-mentor
left a comment
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.
Review Summary
I am requesting changes because there are a few critical issues that prevent the application from functioning as required. Great job on the overall structure, but let's fix these key items.
- Broken Login Flow: In
src/controller/auth.controller.js, yourloginUserfunction callsgenerateTokens(which sends a response) and thenres.redirect(). This causes aCannot set headers after they are senterror, breaking the login functionality. You must choose only one method to end the request. - Missing Access Control: A core requirement is to protect routes based on authentication status. The registration, login, and password reset routes should be for non-authenticated users only, while the logout route must be restricted to authenticated users. This can be fixed by applying the correct middleware in
src/router/auth.router.js. - Unhandled Exception: The
updateNameServiceinsrc/services/user.services.jswill crash the server if a user with the givenidis not found. Please add a check to ensure the user exists before attempting to modify their data.
Once these blockers are addressed, your project will be in excellent shape!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
mateacademy-ai-mentor
left a comment
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.
Review Summary
Great job addressing the critical issues from the last review! The application is much more stable, and the access control is correctly implemented. However, one change is needed before this can be approved. The login functionality no longer meets the requirement to redirect the user to their profile page after a successful login. In src/controller/auth.controller.js, the loginUser function currently sends a JSON response instead of performing a redirect. Please adjust this to ensure the user is redirected, similar to how the activateUser and logout functions work. Once that's fixed, your solution will be in great shape!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
mateacademy-ai-mentor
left a comment
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.
Review Summary
Excellent work on this project, and great job fixing the login redirect from the last review! Your code is very well-structured and meets almost all the requirements.
I am approving this submission to help you keep moving forward, but there is one small change needed to make it perfect. In src/controller/auth.controller.js, the resetPassword function currently sends a JSON response. According to the requirements, it should redirect to a success page. You can fix this by using res.redirect() to send the user to a page that confirms their password has been changed, similar to how you handle redirects after login or activation.
Overall, this is a fantastic submission. Keep up the great work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| user.resetToken = null; | ||
| await user.save(); | ||
|
|
||
| res.json({ message: 'Password changed' }); |
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.
According to the requirements, the application should "Show Success page with a link to login" after a successful password reset. Currently, this function sends a JSON response. Please update this to redirect the user to a success page, similar to how redirects are handled in the activateUser and loginUser functions.
req met