Last post Apr 29, 2019 06:08 AM by Yuki Tao
Apr 27, 2019 06:23 AM|FarhatKhan|LINK
As in below code, password rules defined. I need to add more rules. How can i add more rules in this build in functionality. I need extra rules else defined below.
manager.PasswordValidator = new PasswordValidator
RequiredLength = 6,
RequireNonLetterOrDigit = true,
RequireDigit = true,
RequireLowercase = true,
RequireUppercase = true,
Apr 28, 2019 04:18 PM|emrulkayes2103|LINK
Try the below link. Hope that will be help you
Apr 29, 2019 06:08 AM|Yuki Tao|LINK
First you can create a separate class CustomPasswordValidator which is inherited from IIdentityValidator<string>.
You can then implement validation logic in ValidateAsync(T) method.
There you will retrieve rules from DB and check them against the passed string argument.
Then I suppose you are using a kind of ApplicationUserManager class derived from UserManager.
Add a constructor parameter of IIdentityValidator<string> type to ApplicationUserManager, assign it to PasswordValidator property.
ApplicationUserManager instance created with CustomPasswordValidator instance as an argument will validate you passwords against DB rules.
Refer to this
source of UserManager to see when exactly PasswordValidator property is called.
You could also refer to this link: