Search code examples
c#asp.netvalidationasp.net-core-mvcuser-accounts

asp.net core mvc password validators


What is the easy way to customize password validation rules in asp.net core MVC? The problem is exactly like someone had here How To Change Password Validation in ASP.Net MVC Identity 2? the only difference is that I'm using asp.net CORE MVC (latest build) with Visual Studio 2015. I'd like to remove all password validation rules. There is no ApplicationUserManager class in the project, also I'm not sure if it's possible to customize UserManager validation rules in the Startup.cs file.


Solution

  • If you want simply disable some password restrictions (RequireLowercase, RequiredLength etc) - configure IdentityOptions.Password in Startup, like this:

    services.Configure<IdentityOptions>(o =>
    {
        o.Password.RequiredLength = 12;
    });
    

    If you want completely change password validation logic - implement IPasswordValidator and register it in Startup.