在 UserManager 中找不到 PasswordValidator 属性,AspNet.Identity 3

Cant find PasswordValidator property in UserManager, AspNet.Identity 3

我想更改注册表单的密码要求,但我在 UserManager class.

中找不到 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 的文档是 here。)

所以我设法通过更改 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>();