From ea43290ca033aa4635e2c133ad1fc8b95c4568d2 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 9 Jul 2020 18:31:25 +0100 Subject: [PATCH] fixed previous update --- functions/index.js | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/functions/index.js b/functions/index.js index 6a9bde47f..47f7c35bb 100644 --- a/functions/index.js +++ b/functions/index.js @@ -433,28 +433,29 @@ exports.testCompleted = functions.https.onCall((request, response) => { request.obj.name = name; //check keyspacing and duration here - if (!verified) { - if ( - keySpacing !== null && - keyDuration !== null && - obj.mode === "time" - ) { + if(obj.mode === "time"){ + if (!verified) { if ( - keySpacing.sd < 15 || - keyDuration.sd < 15 || - keyDuration.average < 15 + keySpacing !== null && + keyDuration !== null && ) { - console.error( - `possible bot detected by user (${obj.wpm} ${obj.rawWpm} ${ - obj.acc - }) ${request.uid} ${name} - spacing ${JSON.stringify( - keySpacing - )} duration ${JSON.stringify(keyDuration)}` - ); - return { resultCode: -2 }; + if ( + keySpacing.sd < 15 || + keyDuration.sd < 15 || + keyDuration.average < 15 + ) { + console.error( + `possible bot detected by user (${obj.wpm} ${obj.rawWpm} ${ + obj.acc + }) ${request.uid} ${name} - spacing ${JSON.stringify( + keySpacing + )} duration ${JSON.stringify(keyDuration)}` + ); + return { resultCode: -2 }; + } + } else { + return { resultCode: -3 }; } - } else { - return { resultCode: -3 }; } }