如何删除默认的UserValidator

时间:2016-11-15 15:25:02

标签: c# asp.net-mvc asp.net-core asp.net-identity

我不知道,如何删除/禁用默认的AspNetCore.Identity.UserValidator。 UserManager现在有2个UserValidators:Microsoft.AspNetCore.Identity.UserValidator和Penize_eShop.MyUserValidator

感谢您的帮助

enter image description here

public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddApplicationInsightsTelemetry(Configuration);

    services.AddDbContext<ApplicationDbContext>(options =>
        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

    services.AddIdentity<MyUser, MyRole>(options =>
    {
        options.Password.RequiredLength = 6;
        options.Password.RequireDigit = false;
        options.Password.RequireLowercase = false;
        options.Password.RequireUppercase = false;
        options.Password.RequireNonAlphanumeric = false;
    })
        .AddEntityFrameworkStores<ApplicationDbContext>()
        .AddUserStore<MyUserStore>()
        .AddUserManager<MyUserManager>()
        .AddRoleManager<MyRoleManager>()
        .AddErrorDescriber<MyErrorDescriber>()
        .AddDefaultTokenProviders()
        .AddUserValidator<MyUserValidator<MyUser>>()
        ;

    services.AddScoped<SignInManager<MyUser>, MySignInManager>();
    services.AddScoped<IPasswordHasher<MyUser>, MyPasswordHasher>();

    services.AddMvc();

    // Add application services.
    services.AddTransient<IEmailSender, AuthMessageSender>();
    services.AddTransient<ISmsSender, AuthMessageSender>();
}

0 个答案:

没有答案