在UserManager中找不到PasswordValidator属性,AspNet.Identity 3
本文关键字:AspNet Identity 属性 PasswordValidator UserManager 找不到 | 更新日期: 2023-09-27 18:25:44
我想更改注册表的密码要求,但在UserManager类中找不到PasswordValidator属性。
我使用的是AspNet.Identity.EntityFramework 3.0.0-beta5
private readonly UserManager<AppUser> _userManager;
private readonly SignInManager<AppUser> _signInManager;
public AccountController(UserManager<AppUser> userManager, SignInManager<AppUser> signInManager)
{
_userManager = userManager;
_signInManager = signInManager;
// UserManager does not contain a definition for PasswordValidator
//_userManager.PasswordValidator
}
(为了进行比较,在Microsoft ASP.NET Identity 2.0中,此处提供了UserManager<TUser, TKey>.PasswordValidator
的文档。)
所以我通过更改startup.cs 中的标识选项来修复它
这就是之前的样子
services.AddIdentity<Models.Identity.AppUser, IdentityRole>()
.AddEntityFrameworkStores<test.Models.Identity.IdentityDataContext>();
这就是现在的样子
services.AddIdentity<Models.Identity.AppUser, IdentityRole>(options =>
{
options.Password.RequireDigit = false;
options.Password.RequiredLength = 6;
options.Password.RequireLowercase = false;
options.Password.RequireNonLetterOrDigit = false;
options.Password.RequireUppercase = false;
})
.AddEntityFrameworkStores<test.Models.Identity.IdentityDataContext>();