in C# Asp.Net 5 MVC 6 Identity DEV ~ read.

How to change PasswordValidation in MVC 6

In the Asp.Net MVC 5 using Identity, was possible to do the following:

  manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 6,
                RequireLowercase = true,
                RequireDigit = false,
                RequireUppercase = false
            };  

How to change the same configuration in MVC 6?

Simple!

The Solution Beta6

In the Startup.cs write the code:

services.ConfigureIdentity(options =>  
{
    options.Password.RequireDigit = false;
    options.Password.RequiredLength = 6;
    options.Password.RequireLowercase = false;
    options.Password.RequireNonLetterOrDigit = false;
    options.Password.RequireUppercase = false;
});

The Solution after Beta8

// Add Identity services to the services container.
services.AddIdentity<ApplicationUser, IdentityRole>(options =>  
{
    options.Password.RequireDigit = false;
    options.Password.RequiredLength = 6;
    options.Password.RequireLowercase = false;
    options.Password.RequireNonLetterOrDigit = false;
    options.Password.RequireUppercase = false;
})
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
comments powered by Disqus