Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

Password validator in aspnet identity

$
0
0

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:

var passwordValidator = ServiceLocator.Current.GetInstance<PasswordValidator>();

but it isn't populated with the values I set up in the ApplicationBuilderExtensions.


Viewing all articles
Browse latest Browse all 6894

Trending Articles