From 22677767ea22e5a0df3d81e32b2371f930c66b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Felix=20=C5=A0ulc?= Date: Sat, 13 Jan 2024 11:43:29 +0100 Subject: [PATCH] Provider: fix scoring [closes #65] --- src/ReCaptchaProvider.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ReCaptchaProvider.php b/src/ReCaptchaProvider.php index ba2d44b..b8d98ca 100644 --- a/src/ReCaptchaProvider.php +++ b/src/ReCaptchaProvider.php @@ -63,7 +63,10 @@ public function validate(string $response): ?ReCaptchaResponse $answer = json_decode($response, true); // Return response - return $answer['success'] === true && $answer['score'] >= $this->minimalScore ? new ReCaptchaResponse(true) : new ReCaptchaResponse(false, $answer['error-codes'] ?? null); + return ($answer['success'] === true && ($this->minimalScore <= 0 + || !isset($answer['score']) || $answer['score'] >= $this->minimalScore)) + ? new ReCaptchaResponse(true) + : new ReCaptchaResponse(false, $answer['error-codes'] ?? null); } public function validateControl(BaseControl $control): bool