英文:
Abp.io 7 Change IdentityUser password rules
问题
在abp.io 7和.net 7中,如何在使用IIdentityUserAppService创建IdentityUser或使用IdentityManager时更新密码规则(如RequiredLength、RequireNonAlphanumeric、RequireUppercase等)?
英文:
In abp.io 7, .net 7, how to update password rules (like RequiredLength, RequireNonAlphanumeric, RequireUppercase, etc...) on creating identityuser using IIdentityUserAppService, or on using IdentityManager ?
答案1
得分: 0
我发现了两个问题:
- 更改 IIdentityUserAppService 的密码规则 > 解决方案:
public class XXXSettingDefinitionProvider : SettingDefinitionProvider
{
public override void Define(ISettingDefinitionContext context)
{
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequiredUniqueChars, "6"));
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequireDigit, false.ToString()));
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequireNonAlphanumeric, false.ToString()));
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequireLowercase, false.ToString()));
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequireUppercase, false.ToString()));
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequiredUniqueChars, "0"));
}
}
- 更改 IdentityUserManager 的密码规则 > 解决方案:(在 XXXAplicationModule 中)
Configure<IdentityOptions>(options =>
{
options.Password.RequiredLength = 6;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireLowercase = false;
options.Password.RequireUppercase = false;
options.Password.RequireDigit = false;
options.Password.RequiredUniqueChars = 0;
});
希望对某人有所帮助
英文:
I find 2 problems :
- Change password rules for IIdentityUserAppService > solution :
public class XXXSettingDefinitionProvider : SettingDefinitionProvider
{
public override void Define(ISettingDefinitionContext context)
{
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequiredUniqueChars, "6"));
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequireDigit, false.ToString()));
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequireNonAlphanumeric, false.ToString()));
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequireLowercase, false.ToString()));
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequireUppercase, false.ToString()));
context.Add(new SettingDefinition(IdentitySettingNames.Password.RequiredUniqueChars, "0"));
}
}
- Change password rules for IdentityUserManager > Solution : (in XXXAplicationModule)
Configure<IdentityOptions>(options =>
{
options.Password.RequiredLength = 6;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireLowercase = false;
options.Password.RequireUppercase = false;
options.Password.RequireDigit = false;
options.Password.RequiredUniqueChars = 0;
});
Hope that's help someone
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论