Change user password
POST/company/users/changePass
Allows the authenticated user to change their own password.
Objective
To facilitate secure password changes by the user themselves, maintaining a password history to prevent reuse.
Use Cases
- User wants to change their password periodically
- User forgot their password and used recovery (now wants a personal one)
- Security policy requires regular changes
Authentication
- Requires a valid JWT (middleware m.isLoged)
- User must be authenticated
Validations
- The current password must be valid (model.isValidPassword)
- The new password must match the confirmation
- The new password must meet security requirements:
- Minimum 8 characters
- At least 1 uppercase letter
- At least 1 number
- Cannot be the same as the last 5 passwords used
- Creates a notification upon password change
Process
- User sends current password and new password
- System verifies the current password is correct
- System verifies that new_pass and confirm_pass match
- If valid, updates to the new hashed password
- Clears recovery_token
- Creates a password change notification
- Updates token with m.setNewToken()
Error Messages
- INVALID_PASSWORD (403): Current password is incorrect
- PASSWORD_NOT_MATCH (405): new_pass and confirm_pass do not match
Request
Responses
- 200
- 400
- 401
- 403
- 405
Password changed successfully
Invalid request. Possible causes:
- Missing fields in the request
- Error saving
Unauthorized. Possible causes:
- Invalid or expired JWT token
- User lacks permissions
Current password is incorrect
The new password and confirmation do not match.