How to change PasswordValidator in MVC6 or AspNet Core or IdentityCore

In Asp.Net MVC 5 using Identity, you could do the following:

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

How to change the same configuration in MVC 6?

I see that this could be in the ConfigurationServices method in the segment:

  services.AddIdentity<ApplicationUser, IdentityRole>() .AddPasswordValidator<>() 

But I could not use.

+9
asp.net-mvc asp.net-core asp.net-core-mvc asp.net-identity
Jun 19 '15 at 15:50
source share
1 answer

Beta6 Solution

In 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; }); 

Update Beta8 and RC1

  // 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(); 

Update RC2

  // 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.RequireNonAlphanumeric= false; options.Password.RequireUppercase = false; }) .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); 
+21
Jun 19 '15 at 16:13
source share
— -



All Articles