ALL endpoints in this service require Bearer token authentication. No exceptions. Requests without valid authentication will receive a 401 Unauthorized response.
🚨 Username Change Token Invalidation
CRITICAL: When updating a username via /update-basic-info, the user's current access token becomes invalid immediately after the change. The frontend MUST:
Redirect to login page after successful username change
Clear all stored tokens (access token, refresh token)
Force re-authentication with the new username
Display appropriate message informing user of required re-login
🖼️ Profile Picture URL Restriction
IMPORTANT: The profilePictureUrls field ONLY accepts URLs generated from our File Upload Service endpoint (/api/v1/files/upload). External URLs or direct links are NOT permitted for security reasons.
Valid URL Format: http://localhost:9005/{bucket-name}/{object-key}Source: Must be uploaded through /api/v1/files/upload with directory=PROFILE
Service Overview
The Profile Management Service provides comprehensive user profile management capabilities including profile updates, security settings, verification, and account management.
Base URL
Endpoints Overview
Method
Endpoint
Description
GET
/me
Get current user profile
PUT
/update-basic-info
Update basic profile information
PUT
/change-password
Change user password
GET
/validate-username/{username}
Validate username availability
POST
/request-email-verification
Request email verification
POST
/verify-email
Verify email with OTP
GET
/security-info
Get security information
POST
/enable-2fa
Enable two-factor authentication
POST
/disable-2fa
Disable two-factor authentication
DELETE
/deactivate
Deactivate user account
Get Current User Profile
Retrieves the complete profile information for the authenticated user.
Request
Response
Error Responses
Update Basic Profile Information
Updates basic user profile information including name, email, username, and profile pictures.
Request
Request Body
Field Validation
userName: 3-30 characters, must start with letter, alphanumeric + underscore/hyphen only
firstName: 1-30 characters, required
lastName: 1-30 characters, required
middleName: Max 30 characters, optional
email: Valid email format
phoneNumber: International format (+1234567890)
profilePictureUrls:
Max 5 URLs
Each URL max 500 characters
MUST be URLs from File Upload Service only (/api/v1/files/upload-single with directory=PROFILE)
External URLs are rejected for security reasons
Response (Normal Update)
⚠️ CRITICAL: Username Change Response
When the username is updated, the response includes a special message and the frontend MUST handle token invalidation:
IMMEDIATE ACTION REQUIRED:
Clear all stored tokens (access token, refresh token)
Redirect user to login page
Display the message to inform user of required re-authentication
User must login again with their NEW username
Error Responses
Change Password
Changes the user's password with current password verification.
Request
Request Body
Password Requirements
Minimum 8 characters
At least one uppercase letter
At least one lowercase letter
At least one digit
At least one special character (@$!%*?&#)
Must be different from current password
Response
Error Responses
Validate Username
Checks username availability and format validity with suggestions.
Request
Response (Available)
Response (Not Available)
Request Email Verification
Sends an OTP to the user's email for verification.
Request
Response
Error Responses
Verify Email
Verifies email address using the OTP code sent via email.
Request
Request Body
Response
Error Responses
Get Security Information
Retrieves comprehensive security information and account strength analysis.
Request
Response
Security Strength Scoring
Email Verification: 25 points
Phone Verification: 25 points
Two-Factor Authentication: 35 points
Recent Password Change (last 6 months): 15 points
Security Levels
80-100: STRONG - "Your account security is excellent"
60-79: MEDIUM - "Your account security is good but can be improved"
{
"success": true,
"httpStatus": "OK",
"message": "Username changed successfully! You will be logged out automatically. Please login again with your new username.",
"action_time": "2024-12-09T10:30:00",
"data": { /* updated profile data */ }
}
{
"success": false,
"httpStatus": "BAD_REQUEST",
"message": "Invalid profile picture URL. Only URLs from File Upload Service are allowed.",
"action_time": "2024-12-09T10:30:00"
}
{
"success": false,
"httpStatus": "UNPROCESSABLE_ENTITY",
"message": "Validation failed",
"action_time": "2024-12-09T10:30:00",
"data": {
"userName": "Username must be between 3 and 30 characters",
"email": "Email should be valid",
"profilePictureUrls": "Only URLs from File Upload Service are allowed"
}
}
PUT /api/v1/profile/change-password
Authorization: Bearer {access_token}
Content-Type: application/json
{
"success": false,
"httpStatus": "BAD_REQUEST",
"message": "New password must be different from current password",
"action_time": "2024-12-09T10:30:00"
}
GET /api/v1/profile/validate-username/{username}
Authorization: Bearer {access_token}
{
"success": true,
"httpStatus": "OK",
"message": "Username validation completed",
"action_time": "2024-12-09T10:30:00",
"data": {
"available": true,
"valid": true,
"message": "Username is available",
"suggestions": [],
"details": {
"correctLength": true,
"validFormat": true,
"notReserved": true,
"notTaken": true,
"formatRequirement": "Username must start with a letter and be 3-30 characters long"
}
}
}
{
"success": true,
"httpStatus": "OK",
"message": "Username validation completed",
"action_time": "2024-12-09T10:30:00",
"data": {
"available": false,
"valid": true,
"message": "This username is already taken",
"suggestions": [
"johndoe1",
"johndoe2",
"johndoeuser",
"johndoepro",
"johndoe5634"
],
"details": {
"correctLength": true,
"validFormat": true,
"notReserved": true,
"notTaken": false,
"formatRequirement": "Username must start with a letter and be 3-30 characters long"
}
}
}
POST /api/v1/profile/request-email-verification
Authorization: Bearer {access_token}