Skip to content

Commit

Permalink
Provider: fix scoring [closes #65]
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Jan 13, 2024
1 parent 7c68d59 commit 2267776
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ReCaptchaProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2267776

Please sign in to comment.