34
loading...
This website collects cookies to deliver better user experience
services.AddIdentity<User, IdentityRole>(opt =>
{
// previous code removed for clarity reasons
opt.Lockout.AllowedForNewUsers = true;
opt.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(2);
opt.Lockout.MaxFailedAccessAttempts = 3;
})
password
for a given username
the user account will be locked out for 5 minutes updated accordingly in LockoutEnd
column // AuthService.cs
..
var result = await signInManager.CheckPasswordSignInAsync(user, model.Password, lockoutOnFailure: true);
..
result : SignInResult
we are concerned here are Succeeded
, IsLockedOut
.Succeeded == true
if the username and password matchSucceeded == false
if the username and password do not matchIsLockedOut == true
if this user has been locked out after x number of trialsLockOutEnabled
will become true (1)
in the identity user table. It took me few hours to get to the documentation but it was stated clearly in the Library class.// Microsoft.AspNetCore.Identity.IdentityUser
// Gets or sets a flag indicating if the user could be locked out.
public virtual bool LockoutEnabled { get; set; }
true
for necessary users then locks out the user for particular a time limit set in the config
result.IsLockedOut
flag from the service layer 😅