Endpoint
Authentication
This endpoint requires authentication using a JWT Bearer token.Path Parameters
The username of the user to update
Request Body
All fields in the request body are optional unless otherwise specified.New username for the user. Must be unique across all users.
User’s first name
User’s last name
User’s email address. Must be unique across all users.
User’s phone number. Must be unique across all users.
URL to the user’s profile image. Must be a valid URL.
User biography. Maximum 200 characters.
Current password. Required when changing password (providedNewPassword is set).
New password for the user account. Requires providedOldPassword for verification.
User’s website URL. Must be a valid URL.
User’s gender. Maximum 20 characters.
Enable or disable push notifications
Set account privacy status (true for private, false for public)
Verification status of the account
Request Example
Response
Success Response
Status Code:204 No Content
The user profile was successfully updated. No response body is returned.
Error Responses
Status Code:401 Unauthorized
Returned when:
- No valid JWT Bearer token is provided
- Old password verification fails when changing password
404 Not Found
409 Conflict
Returned when trying to update to a value that’s already taken:
Validation Logic
The endpoint performs the following validations:- Username uniqueness: If updating username, checks that the new username is not already in use by another user
- Email uniqueness: If updating email, verifies the new email is not already registered
- Phone number uniqueness: If updating phone number, ensures it’s not already associated with another account
- Password verification: When changing password, the old password must be provided and verified before the new password is set
Implementation Details
Fromauth.endpoints.cs:54-97, the update handler:
- Loads the user with their profile using
Include(u => u.UserProfile) - Only updates fields that are provided (null fields are ignored)
- Validates uniqueness constraints before updating username, email, or phone number
- Uses
IPasswordHasherto verify old password and hash new password - Updates both User and UserProfile entities in a single transaction
- Returns
204 No Contenton successful update