-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Description
Title: feat(controller): Implement Get User Profile Endpoint
Labels: good first issue, help wanted, hacktoberfest, difficulty: easy, api
Description:
Hello everyone! We need a simple endpoint to allow authenticated users to retrieve their own profile information. This is a great task for beginners as the complex authentication part is already handled by middleware.
🎯 Goal: Complete the getProfile controller function in controllers/authController.js.
📂 File: backend/controllers/authController.js
✅ Acceptance Criteria:
- The
protectmiddleware will have already authenticated the user and attached them toreq.user. - Use the
req.user.idto fetch the user's latest data from the database usingUser.findById(req.user.id). - Ensure the password field is excluded from the result (e.g., using
.select('-password')). - If for some reason the user is not found in the database, return a 404 Not Found error.
- If the user is found, return a 200 OK response with the user's profile data.
🚀 How to Contribute:
- Claim this issue by commenting below.
- Fork, clone, and create a new branch (e.g.,
feat/get-user-profile). - Implement the changes and open a Pull Request.