Skip to content

Feat/profile - #84

Merged
Nabeelahh merged 7 commits into
Vaulty-X:mainfrom
nafiuishaaq:feat/profile
Jul 27, 2026
Merged

Feat/profile#84
Nabeelahh merged 7 commits into
Vaulty-X:mainfrom
nafiuishaaq:feat/profile

Conversation

@nafiuishaaq

Copy link
Copy Markdown

Summary of Changes

  1. Added validation schema: Added updateProfileSchema in auth.validator.ts that validates optional firstName, lastName, and uses the existing phoneNumberField to normalize and validate phone numbers.

  2. Added updateProfile service method: Added updateProfile in auth.service.ts that:

    • Checks if the user exists
    • Only allows updating allowed fields (firstName, lastName, phoneNumber)
    • Validates phone number uniqueness before updating (rejects if another user has the same phone number)
    • Returns the updated user with the same safe shape as getProfile
  3. Added controller method: Added updateProfile in auth.controller.ts that handles the request, extracts the user ID from the authenticated request, calls the service, and returns the response.

  4. Added the route: Added PUT /api/v1/auth/profile in auth.routes.ts that uses the authenticate middleware and the new updateProfileSchema validator.

  5. Created integration tests: Created profile.integration.test.ts that tests:

    • Successful profile updates (names and phone number)
    • Rejection of duplicate phone numbers
    • Rejection of invalid phone numbers
    • That the same safe user shape is returned (no passwordHash, etc.)
    • That unauthenticated requests are rejected

All acceptance criteria have been met! The implementation preserves uniqueness (since phoneNumber is unique in the DB and we check before updating), is audit-safe (since Prisma's updatedAt is automatically updated, and we don't allow changing immutable fields), and all validations are in place.

Closes #77

@Nabeelahh
Nabeelahh merged commit 36f2845 into Vaulty-X:main Jul 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] Add authenticated profile update support

2 participants