Reputation: 1
I'm designing a register form and using ajax to send data to server.
My model:
public class RegisterViewModel
{
[Required]
public string Name { get; set; }
[Required]
public string Email { get; set; }
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }
[DataType(DataType.Password)]
[Compare("Password")]
public string ConfirmPassword { get; set; }
}
and the action:
[HttpPost]
[AllowAnonymous]
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
// do stuff...
}
}
}
My problem: result.Succeeded
returned false
with error message (Password
is helloworld
):
Passwords must have at least one non letter or digit character. Passwords must have at least one digit ('0'-'9'). Passwords must have at least one uppercase ('A'-'Z').
As you can see above, I didn't set any regular expression to Password
and ConfirmPassword
. So why was I getting that?
Upvotes: 2
Views: 2199
Reputation: 2241
Looks like you're using Identity. In the IdentityConfig.cs, there's a section where you configure the requirements for password. Look for this section:
manager.PasswordValidator = new PasswordValidator
{
RequiredLength = 6,
RequireNonLetterOrDigit = true,
RequireDigit = true,
RequireLowercase = true,
RequireUppercase = true,
};
Upvotes: 4