From 6054c974fc971f09525c27f4e6d6b98fff5c6ac0 Mon Sep 17 00:00:00 2001 From: HF Date: Mon, 12 Feb 2024 15:27:19 +0100 Subject: [PATCH] fix race-condition of same captcha ids --- src/data/redis/captcha.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/redis/captcha.js b/src/data/redis/captcha.js index 4677357a..9851edc6 100644 --- a/src/data/redis/captcha.js +++ b/src/data/redis/captcha.js @@ -109,7 +109,7 @@ export async function checkCaptchaSolution( if (!captchaid) { return 4; } - const solution = await client.get(`capt:${captchaid}`); + const solution = await client.getDel(`capt:${captchaid}`); if (solution) { if (evaluateResult(solution, text)) { if (Math.random() < 0.1) { @@ -122,7 +122,7 @@ export async function checkCaptchaSolution( EX: TTL_CACHE, }); } - logger.info(`CAPTCHA ${ip} successfully solved captcha`); + logger.info(`CAPTCHA ${ip} successfully solved captcha ${text}`); return 0; } logger.info(