0

I don't know, how to remove/disable default AspNetCore.Identity.UserValidator. UserManager has 2 UserValidators now: Microsoft.AspNetCore.Identity.UserValidator and Penize_eShop.MyUserValidator

Thanks for help

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>(); } 
3

1 Answer 1

1

You can inherit UserManager and reimplement methods that should behave differently and inject it as the default user manager. Or you can change UserValidator for the concrete instance of the UserManager as follows:

_userManager.UserValidators.Clear(); _userManager.UserValidators.Add(userValidator); // Add your custom validator(s) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.