Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
you should not try to inject the password validator, instead you should use ApplicationUserManager.PasswordValidator where the ApplicationUserManager can be injected of course.
pretty much untested, but this probably works (adding to ConfigureContainer method of one of your IConfigurableModule)
var services = context.Services;
services.AddSingleton<PasswordValidator>((locator) => new PasswordValidator
{
RequiredLength = 6,
RequireNonLetterOrDigit = false,
RequireDigit = false,
RequireLowercase = false,
RequireUppercase = false
});
Then you can add PasswordValidator into your controller via constructor injection (you would need to register a DependencyResolver if you haven't already)
Hi!
We are developing a new Episerver site with aspnet identity. I managed to configure the passwordvalidator like this:
public class ApplicationBuilderExtensions { public static ApplicationUserManager<TUser> CustomApplicationUserManager<TUser>(IdentityFactoryOptions<ApplicationUserManager<TUser>> options, IOwinContext context) where TUser : IdentityUser, IUIUser, new() { var manager = new ApplicationUserManager<TUser>(new UserStore<TUser>(context.Get<ApplicationDbContext<TUser>>())); manager.PasswordValidator = new PasswordValidator { RequiredLength = 6, RequireNonLetterOrDigit = false, RequireDigit = false, RequireLowercase = false, RequireUppercase = false }; (...)
Now I'm wondering how to access this password validator, when validating a password in a controller?
I tried this:
but it isn't populated with the values I set up in the ApplicationBuilderExtensions.