Skip to content

backend/controllers/authController.js - Issue 2 : Implement Get User Profile Endpoint #29

@ivruhs

Description

@ivruhs

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 protect middleware will have already authenticated the user and attached them to req.user.
  • Use the req.user.id to fetch the user's latest data from the database using User.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:

  1. Claim this issue by commenting below.
  2. Fork, clone, and create a new branch (e.g., feat/get-user-profile).
  3. Implement the changes and open a Pull Request.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions