我没有设置密码强度,但是却会出现这个提示框,model中也没类似的设置。
public class RegisterViewModel
{
[Required]
[EmailAddress]
[Display(Name = "电子邮件")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "{0} 必须至少包含 {2} 个字符。", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "密码")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "确认密码")]
[Compare("Password", ErrorMessage = "密码和确认密码不匹配。")]
public string ConfirmPassword { get; set; }
}
问题:如何改变原有密码强度设置?
------解决思路----------------------
如果你用默认的Microsoft.AspNet.Identity做用户认证的话,只需要在创建UserManager<T>的时候,修改其上的PasswordValidator属性:
// Configure validation logic for passwords
manager.PasswordValidator = new PasswordValidator
{
RequiredLength = 6,
RequireNonLetterOrDigit = true, //必须有非字母非数字字符
RequireDigit = true,
RequireLowercase = true,
RequireUppercase = true,
};