identity: fix no error being showed if user is locked out

This commit is contained in:
Abdullah Atta
2024-03-05 10:10:47 +05:00
parent b7e423a3d4
commit e21e2f1510
@@ -87,18 +87,20 @@ namespace Streetwriters.Identity.Validation
if (user == null) return;
var result = await SignInManager.CheckPasswordSignInAsync(user, password, true);
if (!result.Succeeded)
{
await EmailSender.SendFailedLoginAlertAsync(user.Email, httpContext.GetClientInfo(), client).ConfigureAwait(false);
return;
}
else if (result.IsLockedOut)
if (result.IsLockedOut)
{
var timeLeft = user.LockoutEnd - DateTimeOffset.Now;
context.Result = new LockedOutValidationResult(timeLeft);
return;
}
if (!result.Succeeded)
{
await EmailSender.SendFailedLoginAlertAsync(user.Email, httpContext.GetClientInfo(), client).ConfigureAwait(false);
return;
}
var sub = await UserManager.GetUserIdAsync(user);
context.Result = new GrantValidationResult(sub, AuthenticationMethods.Password);
}