在使用Identity的Asp.Net MVC 5中,可以执行以下操作:
manager.PasswordValidator = new PasswordValidator { requiredLength = 6,RequireLowercase = true,requiredigit = false,RequireUppercase = false };
如何在MVC 6中更改相同的配置?
我看到可以在段中的ConfigurationServices方法中:
services.AddIdentity<ApplicationUser,IdentityRole>() .AddPasswordValidator<>()
但我无法使用.
解决方法
解决方案Beta6
在Startup.cs中编写代码:
services.ConfigureIdentity(options => { options.Password.requiredigit = false; options.Password.requiredLength = 6; options.Password.RequireLowercase = false; options.Password.RequireNonLetterOrDigit = false; options.Password.RequireUppercase = false; });
更新Beta8和RC1
// Add Identity services to the services container. services.AddIdentity<ApplicationUser,IdentityRole>(options => { options.Password.requiredigit = false; options.Password.requiredLength = 6; options.Password.RequireLowercase = false; options.Password.RequireNonLetterOrDigit = false; options.Password.RequireUppercase = false; }) .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders();
更新RC2
// Add Identity services to the services container. services.AddIdentity<ApplicationUser,IdentityRole>(options => { options.Password.requiredigit = false; options.Password.requiredLength = 6; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric= false; options.Password.RequireUppercase = false; }) .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders();
原文地址:https://www.jb51.cc/netcore/246207.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。