1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 17:42:49 -05:00

[Captcha] BUG Add null checks | Make ceiling default to zero (#1903)

* [Captcha] BUG Add null checks | Make ceiling default to zero

* Formatting
This commit is contained in:
Vincent Salucci
2022-03-09 12:07:06 -06:00
committed by GitHub
parent 7620433d7e
commit 7046aecfd5
7 changed files with 15 additions and 10 deletions

View File

@ -515,7 +515,7 @@ namespace Bit.Core.IdentityServer
private async Task ResetFailedAuthDetailsAsync(User user)
{
// Early escape if db hit not necessary
if (user.FailedLoginCount == 0)
if (user == null || user.FailedLoginCount == 0)
{
return;
}
@ -527,6 +527,11 @@ namespace Bit.Core.IdentityServer
private async Task UpdateFailedAuthDetailsAsync(User user, bool twoFactorInvalid, bool unknownDevice)
{
if (user == null)
{
return;
}
var utcNow = DateTime.UtcNow;
user.FailedLoginCount = ++user.FailedLoginCount;
user.LastFailedLoginDate = user.RevisionDate = utcNow;