我不知道,如何删除/禁用默认的AspNetCore.Identity.UserValidator。 UserManager现在有2个UserValidators:Microsoft.AspNetCore.Identity.UserValidator和Penize_eShop.MyUserValidator
感谢您的帮助
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>();
}