-
Notifications
You must be signed in to change notification settings - Fork 238
Wrong message for password policies #649
Description
PassCore Server
- OS: Windows
- Provider: Active Directory
Describe the bug
When I try to change my password but my password policies don't accept the new password (ex. password too recent), the error message I get is "Failed due to password complex policies: New password length is shorter than AD minimum password length".
To Reproduce
Steps to reproduce the behavior:
- Have a Windows Server (2019) with default security policies
- Change the password of user 'test'
- Install PassCore
- Try to change the password of user 'test' again
Expected behavior
There should have been an error message saying there was an error due to my password policies, instead of a message "my new password is too short"
Desktop (please complete the following information):
- OS: Arch Linux
- Browser: Mozilla Firefox
- Version: 91.0.1
Additional context
It seems to be because when there is a PasswordException during the password change, it returns the same error as when the password is too short:
passcore/src/Unosquare.PassCore.PasswordProvider/PasswordChangeProvider.cs
Lines 106 to 113 in cd559d3
| catch (PasswordException passwordEx) | |
| { | |
| var item = new ApiErrorItem(ApiErrorCode.ComplexPassword, passwordEx.Message); | |
| _logger.LogWarning(item.Message, passwordEx); | |
| return item; | |
| } |
When the password is too short:
passcore/src/Unosquare.PassCore.PasswordProvider/PasswordChangeProvider.cs
Lines 56 to 61 in cd559d3
| if (newPassword.Length < minPwdLength) | |
| { | |
| _logger.LogError("Failed due to password complex policies: New password length is shorter than AD minimum password length"); | |
| return new ApiErrorItem(ApiErrorCode.ComplexPassword); | |
| } |