简体   繁体   English

如果用户登录在Asp.Net Core标识中连续失败,如何禁用帐户

[英]How to disable account if user login fails continuously in Asp.Net Core identity

Currently, I'm using Asp.net core 1.1, EF core & Asp.net core Identity in my system. 目前,我在我的系统中使用Asp.net核心1.1,EF核心和Asp.net核心身份。 I have a configure below in startup.cs class for the password policy. 我在startup.cs类中有一个配置密码策略。

Is there a configure to disable account when a user continuously login fails? 是否有配置在用户连续登录失败时禁用帐户?

services.Configure<IdentityOptions>(options =>
{
    // Password settings
    options.Password.RequireDigit = true;
    options.Password.RequiredLength = 6;
    options.Password.RequireNonAlphanumeric = true;
    options.Password.RequireUppercase = true;
    options.Password.RequireLowercase = true;
}

You can simply do it like this 你可以这样做

options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(30);
options.Lockout.MaxFailedAccessAttempts = 5;
options.Lockout.AllowedForNewUsers = true;

For more details see this link 有关详细信息,请参阅此链接

In your account controller, scroll down to public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) 在您的帐户控制器中,向下滚动到public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)

Once there, set shouldLockout to true 在那里,将shouldLockout设置为true

var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM