“Abp.io 7 更改 IdentityUser 密码规则”

huangapple go评论140阅读模式
英文:

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

我发现了两个问题:

  1. 更改 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"));
    }
}
  1. 更改 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;
});

希望对某人有所帮助 “Abp.io 7 更改 IdentityUser 密码规则”

英文:

I find 2 problems :

  1. Change password rules for IIdentityUserAppService > solution :
public class XXXSettingDefinitionProvider : SettingDefinitionProvider
{
    public override void Define(ISettingDefinitionContext context)
    {
        context.Add(new SettingDefinition(IdentitySettingNames.Password.RequiredUniqueChars, &quot;6&quot;));
        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, &quot;0&quot;));
    }
}
  1. Change password rules for IdentityUserManager > Solution : (in XXXAplicationModule)
Configure&lt;IdentityOptions&gt;(options =&gt;
        {
            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 “Abp.io 7 更改 IdentityUser 密码规则”

huangapple
  • 本文由 发表于 2023年4月19日 18:23:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76053384.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定