Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Why IPasswordValidator override the built in asp.net core password validation?

$
0
0

i have the following code in the startup class in asp.net core 2.0 app

public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<AppIdentityDbContext>(options =>
                options.UseSqlServer(Configuration["Data:SportStoreIdentity:ConnectionString"])
                );


            // a custom class to validate passwords
            services.AddTransient<IPasswordValidator<AppUser>, CustomPasswordValidator>();

            services.AddIdentity<AppUser, IdentityRole>(opts =>
            {
                // those options are overriden by the CustomPasswordValidator class if present
                // as a dependency injection
                opts.Password.RequireDigit = true;
                opts.Password.RequiredLength = 1;
                opts.Password.RequireLowercase = false;
                opts.Password.RequireNonAlphanumeric = false;
                opts.Password.RequireUppercase = false;


                opts.User.RequireUniqueEmail = true;
                
            })
                .AddEntityFrameworkStores<AppIdentityDbContext>()
                .AddDefaultTokenProviders();

            services.AddMvc();
        }

why CustomPasswordValidator override rules introduced by the AddIdentity method?

how that works?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>