Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Update profile endpoint #275

Merged
merged 6 commits into from
Aug 6, 2024
Merged

Conversation

Cyberguru1
Copy link
Contributor

Description

This PR implements a new API endpoint to allow users to update their profile information.

Endpoint Definition

  • Method: PATCH
  • URL: /api/v1/profile
  • Authentication: Required (JWT token)

Request Body

  • first_name (string, optional)
  • last_name (string, optional)
  • phone (string, optional)
  • secondary_email (string, optional)
{
  "first_name": "new_username",
  "last_name": "New Full Name",
  "phone": "1234567890",
  "secondary_email": "[email protected]"
}

Response

Success (200 OK)

{
  "message": "Profile updated successfully"
}

Failure

  • 400 Bad Request: If any of the provided data is invalid.
  • 401 Unauthorized: If the user is not authenticated.
  • 500 Internal Server Error: If there is an error updating the profile.

Error Handling

  • Provide meaningful error messages for validation failures and other errors.

Security Considerations

  • Ensure only authenticated users can update their profiless:

Backend Implementation

  • Create the updateProfileHandler function to handle the logic for updating the profile information.
  • Authenticate the user using the JWT token.
  • Validate the provided data.
  • Update the user's profile information in the database.
  • Return appropriate success or error responses.

Related Issue

Implement Update Profile Endpoint

How Has This Been Tested?

  • Unit tests have been written for the updateProfileHandler function to ensure proper validation and updating of profile information.
  • Integration tests have been conducted to verify that the endpoint works as expected when invoked.

Screenshots (if appropriate - Postman, etc):

image

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Cyberguru1 Cyberguru1 self-assigned this Aug 6, 2024
Micah-Shallom
Micah-Shallom previously approved these changes Aug 6, 2024
Copy link
Contributor

@Micah-Shallom Micah-Shallom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@Micah-Shallom Micah-Shallom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Micah-Shallom Micah-Shallom merged commit 51a7971 into dev Aug 6, 2024
4 checks 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.

2 participants