Before anyone suggests that this is the same question as the link below:
How To Change Password Validation in ASP.Net MVC Identity 2?
I would like to assure people that it is more of a continuation of this question.
I went into the IdentityConfig.cs as the first answer to the above link suggested and changed all the options as follows:
manager.PasswordValidator = new PasswordValidator
{
RequiredLength = 2,
RequireNonLetterOrDigit = false,
RequireDigit = false,
RequireLowercase = false,
RequireUppercase = false,
};
Next, as the second answer suggested I also went into the AccountViewModels.cs class and changed the 2 places there which sets the minimum length of the password. I again set it from 6 to 2 (in both places it appears within the file.
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 2)]
I then went ahead and done a search for the phrase "must be at least" throughout the entire solution. I found one other class: ManageViewModels.cs and again in the two places this appeared I altered the minimum length setting it from 6 to 2 in both places, just as above.
I am trying to setup some default roles and a super user in the Startup.cs (Personally I would not do it this way, but I am just following an article on securing my CMS). One of the first steps is this.
In my Startup.cs I have the following simple code:
//Here we create a Admin super user who will maintain the website
var user = new ApplicationUser();
user.UserName = "super";
user.Email = "super@krypton.com";
string userPWD = "1234";
IdentityResult chkUser = UserManager.Create(user, userPWD);
//Add default User to Role Admin
if (chkUser.Succeeded)
{
IdentityResult result1 = UserManager.AddToRole(user.Id, "Admin");
}
It should work. But when I break on it, and hover over the chkUser variable, I find that I am getting an error saying "The Password must be at least 6 characters long.".
Even after changing all the validation logic to say it should be 2 characters.
So my question is: Is there another location where yet more validation logic is done? Also, is there a single place where I can extract all this validation logic to (if so, can someone perhaps suggest a link or two to such a resource or provide a suggestion on how to approach it).