如何改变PasswordValidator在MVC6或ASPNET核心或IdentityCore [英] How to change PasswordValidator in MVC6 or AspNet Core or IdentityCore
本文介绍了如何改变PasswordValidator在MVC6或ASPNET核心或IdentityCore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Asp.Net MVC 5使用Identity,是可以做到以下几点:
In the Asp.Net MVC 5 using Identity, was possible to do the following:
manager.PasswordValidator = new PasswordValidator
{
RequiredLength = 6,
RequireLowercase = true,
RequireDigit = false,
RequireUppercase = false
};
如何更改MVC 6相同的配置?
How to change the same configuration in MVC 6?
我看可以在ConfigurationServices方法段:
I see that can be in ConfigurationServices method in the segment:
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddPasswordValidator<>()
但我不能使用。
推荐答案
解决方案Beta6
The Solution Beta6
在 Startup.cs
写code:
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
Update Beta8 and 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
Update 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();
这篇关于如何改变PasswordValidator在MVC6或ASPNET核心或IdentityCore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文