Change Password API
Overview
Allows a user to change their password by verifying their existing oldPassword against stored passwordHash using bcrypt before updating.
- Endpoint:
/api/auth/change-password - Method:
POSTorGET - Auth Required: Optional / Public
Request Parameters (Body / Query)
| Field | Type | Required | Description |
|---|---|---|---|
emailId | String | Yes (or email) | User's registered email address |
oldPassword | String | Yes | Existing current password |
password | String | Yes | New password (min 6 characters) |
confirmPassword | String | Yes | Confirmation matching password |
Example Request Body
{
"emailId": "user@example.com",
"oldPassword": "OldPassword123!",
"password": "NewSecurePassword123!",
"confirmPassword": "NewSecurePassword123!"
}
Responses
Success Response (200 OK)
{
"success": true,
"message": "Password Updated",
"data": null
}
Invalid Old Password (400 Bad Request)
{
"success": false,
"message": "Invalid old password",
"data": null
}