Skip to main content

Get User Profile

GET /api/me
Retrieves the authenticated user’s profile information.

Headers

Authorization
string
required
Bearer token for authentication

Response

success
string
Indicates if the request was successful
data
object
User profile information
{
  "data": {
    "_id": "507f1f77bcf86cd799439011",
    "fullname": "John Doe",
    "email": "john@example.com",
    "provider": "local",
    "profilePic": "https://cdn.deployhub.online/profile-123.jpg",
    "verified": true,
    "updatedAt": "2024-03-15T10:30:00.000Z",
    "createdAt": "2024-01-10T08:15:00.000Z"
  },
  "success": "true"
}

Update Profile Picture

POST /api/user/profile-pic
Uploads and updates the user’s profile picture. Uses multipart/form-data with multer middleware.

Headers

Authorization
string
required
Bearer token for authentication
Content-Type
string
required
Must be multipart/form-data

Body Parameters

profilePic
file
required
Image file for the profile picture. Uploaded using multer with diskStorage configuration. Files are temporarily stored in the uploads/ directory with a unique filename format: profilePic-{timestamp}-{random}.{ext}

Response

message
string
Success message
profilePic
string
Public URL of the uploaded profile picture
{
  "message": "Profile picture updated successfully",
  "profilePic": "https://cdn.deployhub.online/profile-1234567890.jpg"
}

Implementation Details

  • Multer storage configuration uses diskStorage with unique filename generation
  • Old profile picture is deleted from Devload storage before uploading new one
  • File is uploaded to Devload CDN and public URL is stored in database
  • Local temporary file is automatically cleaned up after upload
  • Updates both profilePic (URL) and profilefileid (storage reference) fields

Error Responses

{
  "message": "File upload failed"
}
{
  "message": "File deletion failed"
}
{
  "message": "Internal server error"
}

Update Full Name

PUT /api/user/fullname
Updates the user’s full name.

Headers

Authorization
string
required
Bearer token for authentication
Content-Type
string
required
Must be application/json

Body Parameters

fullname
string
required
New full name for the user
{
  "fullname": "Jane Smith"
}

Response

success
boolean
Indicates if the update was successful
{
  "success": true
}

Error Responses

{
  "message": "fullname is required"
}
{
  "error": "internal Server Error"
}

Initialize Email Verification Payment

POST /api/me/init
Initiates a Razorpay payment order for email verification. Users must pay ₹99 to verify their email address.

Headers

Authorization
string
required
Bearer token for authentication

Response

id
string
Razorpay order ID
amount
number
Payment amount in paise (9900 = ₹99)
currency
string
Currency code (INR)
receipt
string
Order receipt ID
{
  "id": "order_NXHk3Mxl9rDEJZ",
  "amount": 9900,
  "currency": "INR",
  "receipt": "order_rcptid_0.123456789"
}

Implementation Details

  • Creates a Razorpay order with amount ₹99 (9900 paise)
  • Customer details (email, name) are automatically included
  • Creates a VerifyuserPayment record with status pending
  • Order ID is stored for verification

Error Responses

{
  "error": "Internal Server Error"
}

Verify Email Verification Payment

POST /api/me/verify
Verifies the Razorpay payment signature and marks the user’s email as verified.

Headers

Authorization
string
required
Bearer token for authentication
Content-Type
string
required
Must be application/json

Body Parameters

razorpay_payment_id
string
required
Payment ID from Razorpay checkout
razorpay_order_id
string
required
Order ID from the init endpoint
razorpay_signature
string
required
HMAC signature from Razorpay for verification
{
  "razorpay_payment_id": "pay_NXHk3Mxl9rDEJZ",
  "razorpay_order_id": "order_NXHk3Mxl9rDEJZ",
  "razorpay_signature": "9ef9e5c5c9c5e5c5c9c5e5c5c9c5e5c5"
}

Response

success
boolean
Indicates if verification was successful
verifed
boolean
Indicates if the user is now verified
{
  "success": true,
  "verifed": true
}

Implementation Details

  • Verifies payment signature using HMAC-SHA256
  • Checks if order exists and matches user
  • Prevents duplicate verification (checks if status is already completed)
  • Updates user’s verified field to true
  • Sets verifiedAt timestamp
  • Updates order status to completed

Error Responses

{
  "message": "required details fro verify payment"
}
{
  "success": false,
  "message": "Payment verification failed!"
}
{
  "message": "User not found!"
}
{
  "message": "something went wrong! PLease Contact your team"
}
{
  "message": "Your Oder ALready PRocessed"
}
The signature verification is critical for security. Never skip this step or accept unverified payments.