Wednesday 4 February 2015

How To Change Password Validation strength in ASP.Net MVC Identity ?

In the MVC project template in VS2013 Update 2, there should be a file called App_Start/IdentityConfig.cs.

In it you should find the class ApplicationUserManager and a static factory method called Create().

That's where the user manager class is configured, including the server-side validation rules for passwords are defined. For example:

manager.PasswordValidator = new PasswordValidator
{
    RequiredLength = 6,
    RequireNonLetterOrDigit = true,
    RequireDigit = true,
    RequireLowercase = true,
    RequireUppercase = true,
};

Note: you can change/customize above configuration for password strength, like this:

// Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 6,
                RequireNonLetterOrDigit = false,
                RequireDigit = false,
                RequireLowercase = false,
                RequireUppercase = false,
            };

Enjoyyyy...

0 comments:

Post a Comment


                                                            
 
Design by Abhinav Ranjan Sinha