Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. I have a configure below in startup.cs class for the password policy.

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;
}
like image 845
Hung Quach Avatar asked Dec 05 '25 09:12

Hung Quach


1 Answers

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

like image 63
Ghulam Mohayudin Avatar answered Dec 07 '25 21:12

Ghulam Mohayudin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!