When an incorrect old password is entered in the Change password form, authentication failure is logged, but the password change still proceeds. This is a serious security bug.
Solution
The server responds with 401 immediately after the failed old password verification.
This should be considered a hotfix - a proper refactoring is needed:
ChangePasswordHandler should not perform any verification or flow control.
ChangePasswordService needs to conduct the entire password change process, including sending the messages etc.
ChangePasswordService needs to have a specific Error class for every unhappy flow. The Handler must catch those and translate them into HTTP responses.
Unit tests must be created for all ChangePasswordService methods.
Issue
When an incorrect old password is entered in the Change password form, authentication failure is logged, but the password change still proceeds. This is a serious security bug.
Solution
The server responds with 401 immediately after the failed old password verification.
This should be considered a hotfix - a proper refactoring is needed: