From 859d2d54c6844a06bb4e6a3098179acb551c165c Mon Sep 17 00:00:00 2001 From: Archi Date: Wed, 21 Jul 2021 09:58:09 +0200 Subject: [PATCH] Misc --- .../IPC/Integration/ApiAuthenticationMiddleware.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs b/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs index a1f71cba7..d9e028fe5 100644 --- a/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs +++ b/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs @@ -163,14 +163,14 @@ namespace ArchiSteamFarm.IPC.Integration { await AuthorizationSemaphore.WaitAsync().ConfigureAwait(false); try { - if (FailedAuthorizations.TryGetValue(clientIP, out attempts)) { - if (attempts >= MaxFailedAuthorizationAttempts) { - return (HttpStatusCode.Forbidden, false); - } + bool hasFailedAuthorizations = FailedAuthorizations.TryGetValue(clientIP, out attempts); + + if (hasFailedAuthorizations && (attempts >= MaxFailedAuthorizationAttempts)) { + return (HttpStatusCode.Forbidden, false); } if (!authorized) { - FailedAuthorizations[clientIP] = FailedAuthorizations.TryGetValue(clientIP, out attempts) ? ++attempts : (byte) 1; + FailedAuthorizations[clientIP] = hasFailedAuthorizations ? ++attempts : (byte) 1; } } finally { AuthorizationSemaphore.Release();