From fbe022e4be5508003a0e8ce92455715efc2bcf2b Mon Sep 17 00:00:00 2001 From: olcxja Date: Fri, 1 May 2026 20:09:07 +0200 Subject: [PATCH] Improve nonce caching --- LarpixServer/Account/Requests.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/LarpixServer/Account/Requests.cs b/LarpixServer/Account/Requests.cs index b707132..568e953 100644 --- a/LarpixServer/Account/Requests.cs +++ b/LarpixServer/Account/Requests.cs @@ -326,27 +326,15 @@ public class Requests string plainPass = await Utils.GetPassword(await Utils.IdFromName(username)); foreach (var kvp in nonceHolder) //clearowanie nieuzytych nonce { - /* - if (kvp.Key == username) - { - nonceHolder.TryRemove(kvp.Key, out _); - } - */ //tak teraz sobie mysle moze jednak nie usuwac nonce?? bo co jak jakis cep beedzie ciagle komus spamic i - //bedzie mial nizszy ping i gosc nie bedzie mogl zadnego req wyslac, a nawet jak ktos bez secret to odczyta - //to nic z tym nie zrobi if (kvp.Value.Item2 < DateTimeOffset.UtcNow.AddMinutes(-2)) { nonceHolder.TryRemove(kvp.Key, out _); } else if (kvp.Key == username) { - if (nonceHolder.TryGetValue(kvp.Key, out (string, DateTimeOffset) cachedNonce)) - { - await context.Response.WriteAsync(Encryption.Encryption.EncryptString(cachedNonce.Item1, - plainPass)); - - return; - } + await context.Response.WriteAsync(Encryption.Encryption.EncryptString(kvp.Value.Item1, + plainPass)); + return; } }