Overview
This endpoint allows authenticated users to change their password. It requires the current password for verification and a new password with confirmation.This endpoint requires authentication. Include a valid JWT token in the Authorization header.
Endpoint
Authentication
This endpoint requires authentication using a JWT Bearer token.Request Body
The user’s current password
- Minimum length: 8 characters
- Validation: Required, must match the user’s current password
- Custom Rule:
CheckPasswordRulevalidates that this matches the current password in the database
The new password
- Minimum length: 8 characters
- Validation: Required, must be confirmed
- Security: Will be hashed using bcrypt before storage
Confirmation of the new password
- Validation: Must match the
passwordfield exactly
Response
Indicates whether the request was successful
A message describing the result (localized based on Accept-Language header)
This endpoint does not return user data for security reasons
Example Request
Example Response
200 - Success
401 - Unauthorized
422 - Validation Error (Invalid Current Password)
422 - Validation Error (Password Mismatch)
422 - Validation Error (Password Too Short)
500 - Server Error
Validation Rules
The following validation rules are applied to the request:| Field | Rules | Description |
|---|---|---|
old_password | required, min:8, CheckPasswordRule | Current password (must match existing password) |
password | required, confirmed, min:8 | New password (minimum 8 characters) |
password_confirmation | required (implicit) | Must match the password field |
The
CheckPasswordRule is a custom validation rule that verifies the provided old_password matches the user’s current password in the database.Security Features
- Current Password Verification: The
CheckPasswordRulecustom validator ensures the user knows their current password - Password Confirmation: The new password must be confirmed to prevent typos
- Bcrypt Hashing: The new password is hashed using bcrypt before being stored in the database
- Minimum Length: Both current and new passwords must be at least 8 characters
- No Password Return: For security, the response does not include the new password
Implementation Details
This endpoint is implemented inUserController.php:88 and uses the following:
- Controller Method:
UserController::updatePassword() - Request Validation:
UpdatePasswordRequest(defined inapp/Http/Requests/User/UpdatePasswordRequest.php:23) - Custom Validation Rule:
CheckPasswordRule(validates current password) - Password Hashing:
bcrypt()function (defined atUserController.php:97) - Authentication Guard:
auth('api') - Route Name:
user.password.update
Related Endpoints
- Get User Profile - Retrieve current user information
- Update User Profile - Update user’s basic information
- Reset Password - Reset password via email (when user forgot password)