Skip to content

[Bug] Signup avatar isn’t persisted and does not store the Avatar image of the user #64

@Hardik-Kumar0005

Description

@Hardik-Kumar0005

Describe the bug
Submitting the signup form with a profile image succeeds, but the created user record still has an empty avatarUrl. The controller saves the payload under profilPic, a field that doesn’t exist on the User model, so the avatar never makes it into MongoDB databse and the frontend doesn't show the User's avatar picture.

To Reproduce
Steps to reproduce the behavior:

  1. Run the backend locally (npm run dev) with a valid MongoDB connection.
  2. Send a POST request to http://localhost:8080/api/v1/auth/signup with JSON:
  3. Inspect the 201 response and the users collection in MongoDB.
  4. Notice avatarUrl is an empty string even though an image URL was provided.

Expected behavior
If a caller supplies an avatar URL (or base64 image), the server should persist it to User.avatarUrl and return the same value in the signup response so the profile displays immediately after account creation.

Screenshots

  • API endpoint response - shows even if we pass a ProfilPic the response and db doesn't actually store the image url
Image - Mongodb database Image
  • Code snippet
Image

Why this is happening?

  • The User schema only defines avatarUrl so from the payload the value that is being parsed as profilePIc is dropped.
Image

Proposed solution

Update the signup controller to destructure avatarUrl from the payload instead of profilePic solve the issue.


Desktop (please complete the following information):

  • OS: Windows 11, Arch Linux
  • Browser: chrome, firefox
  • Version: Latest

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser: N/A
  • Version: N/A

Additional context
user.controller.js still destructures profilPic from req.body and passes it to the User constructor. The User schema only defines avatarUrl so the value is dropped. Aligning the payload and controller to use avatarUrl resolves the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions