我使用 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();
密码规则似乎有效,但锁定规则无效。有什么我需要启用的吗?
不知道我是怎么错过这个的。锁定功能发生作为登录过程中的一部分PasswordSignInAsync
上的方法SignInManager
。我需要更改的代码行是以下Login
方法的一部分AccountController
:
SignInManager.PasswordSignInAsync(
model.Email,
model.Password,
model.RememberLogin,
lockoutOnFailure: true); // <- HERE
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句