This policy demonstrates how to prevent the user from using the last password when changing the password. For scenarios where you need to implement a password reset/change flow where the user cannot use their currently set password.
To test the policy, follow these steps:
-
If you don't have an account, create a local account with your email address.
-
Run the B2C_1A_Demo_PasswordReset_NotLastPassword policy to reset the password
-
Perform the following tests:
- Enter valid current password, and the same password for new password and re-enter password, then select continue. You should get an error message that the old and new password are identical.
- Enter invalid current password. You should get an error message that the current password is invalid.
- Enter valid current password, and a different password for new password and re-enter password. You should be able to completed the process successfully.
- Try to sign-in with your updated password.
This sample presents the user with a screen to enter their current password, new password and re-enter password field using the LocalAccountWritePasswordUsingObjectId technical profile. This technical profile calls validation technical profiles in the following order:
- login-NonInteractive-PasswordChange to validate the current password.
- ComparePasswords to ensure that the new password is not the same as the current password. It invokes the claims transformation in the following order:
- CheckPasswordEquivalence - does a string comparison operation against the new password and the current password. If they match, it outputs
True
, otherwiseFalse
. - AssertSamePasswordIsFalse - asserts that the boolean from step 1 came back as
False
, indicating the password was different.
- CheckPasswordEquivalence - does a string comparison operation against the new password and the current password. If they match, it outputs
- Finally the password is written using AAD-UserWritePasswordUsingObjectId technical profile.
Use Stack Overflow to get support from the community. Ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before. Make sure that your questions or comments are tagged with [azure-ad-b2c]. If you find a bug in the sample, please raise the issue on GitHub Issues. To provide product feedback, visit the Azure Active Directory B2C Feedback page.