【问题标题】:ASP.NET Core Identity Settings Not WorkingASP.NET Core 标识设置不起作用
【发布时间】:2017-06-22 16:03:26
【问题描述】:

我使用 ASP.NET Identity 实现了 Identity Server 4。我之前问了一个关于如何应用某些登录规则的问题,并收到了解释如何在Startup.cs 中添加一些选项的答案。这是我在ConfigureServices 方法中添加的内容:

services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{
    options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(15);
    options.Lockout.MaxFailedAccessAttempts = 5;
    options.Password.RequiredLength = 9;
    options.Password.RequireDigit = true;
    options.Password.RequireLowercase = true;
    options.Password.RequireUppercase = true;
    options.Password.RequireNonAlphanumeric = false;
    options.SignIn.RequireConfirmedEmail = true;
})
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();

密码规则似乎有效,但锁定规则无效。有什么我需要启用的吗?

【问题讨论】:

    标签: identityserver3 identityserver4


    【解决方案1】:

    不知道我是怎么错过的。锁定功能在SignInManager 上的PasswordSignInAsync 方法中作为登录过程的一部分发生。我需要更改的代码行是AccountControllerLogin 方法的一部分:

    SignInManager.PasswordSignInAsync(
        model.Email,
        model.Password,
        model.RememberLogin,
        lockoutOnFailure: true); // <- HERE
    

    【讨论】:

      猜你喜欢
      • 2022-06-13
      • 2021-03-20
      • 2018-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多