fix: add error handling to authentication controllers#56
Conversation
|
@om-dev007 is attempting to deploy a commit to the rishabhjtripathi2903-3434's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesAuth Controller Error Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/src/controllers/authController.ts`:
- Around line 64-67: The catch blocks in authController.ts are exposing raw
error messages to clients, which leaks internal implementation details and
violates security practices. In both the catch block around lines 64-67 and the
one around lines 103-105, replace the dynamic error.message with a fixed generic
message like "Internal server error" in the res.status(500).json() response.
Keep the detailed error information (error.message and full error object) only
in server-side logging using a logger or console.error so debugging information
is available internally but not exposed to clients.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 049a1f9a-7534-4ace-90f3-9eabb34ea26f
📒 Files selected for processing (1)
backend/src/controllers/authController.ts
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@Rishabhworkspace please review the latest commit |
Summary
This PR adds proper error handling to authentication controllers by wrapping asynchronous operations in try-catch blocks.
Changes Made
Added try-catch blocks to registerUser
Added try-catch blocks to loginUser
Improved error handling for authentication-related operations
Added server error responses for unexpected failures
Added error logging for easier debugging
Why
Authentication controllers perform multiple asynchronous operations such as database queries and password hashing. Without proper error handling, unexpected failures can lead to unhandled exceptions and inconsistent API responses.
Issue
Closes #53
Summary by CodeRabbit