From 41826075aa568a2d165fe8c0925a46c84ae9e4cb Mon Sep 17 00:00:00 2001 From: Miodec Date: Fri, 7 Jan 2022 15:50:05 +0100 Subject: [PATCH] validating later --- backend/api/controllers/result.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/backend/api/controllers/result.js b/backend/api/controllers/result.js index 6c2717b36..4f26eab4d 100644 --- a/backend/api/controllers/result.js +++ b/backend/api/controllers/result.js @@ -96,19 +96,6 @@ class ResultController { ) { return res.status(400).json({ message: "Test too short" }); } - if (validateResult) { - if (!validateResult(result)) { - return res - .status(400) - .json({ message: "Result data doesn't make sense" }); - } - } else { - console.error("=============================="); - console.error( - "No anticheat module found, results will not be validated!" - ); - console.error("=============================="); - } let resulthash = result.hash; delete result.hash; @@ -126,6 +113,20 @@ class ResultController { return res.status(400).json({ message: "Incorrect result hash" }); } + if (validateResult) { + if (!validateResult(result)) { + return res + .status(400) + .json({ message: "Result data doesn't make sense" }); + } + } else { + console.error("=============================="); + console.error( + "No anticheat module found, results will not be validated!" + ); + console.error("=============================="); + } + result.timestamp = Math.round(result.timestamp / 1000) * 1000; //dont use - result timestamp is unreliable, can be changed by system time and stuff