Skip to content

Commit

Permalink
Merge pull request #3 from kodumbeats/feat-score-recaptcha-v3
Browse files Browse the repository at this point in the history
Allow custom score thresholds for reCAPTCHA
  • Loading branch information
eldadfux committed Mar 17, 2021
2 parents b2772e7 + 66eb894 commit 2b8cc40
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Abuse/Adapters/ReCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ public function __construct($secret, $response, $remoteIP)
/**
* Check
*
* Check if user is human or not
* Check if user is human or not, compared to score
*
* @param float $score
* @return bool
*/
public function check()
public function check($score = 0.5):bool
{
$url = 'https://www.google.com/recaptcha/api/siteverify';
$fields = array(
Expand All @@ -77,8 +80,11 @@ public function check()

//close connection
\curl_close($ch);

return $result['success'];
if ($result['success'] && $result['score'] < $score ) {
return true;
} else {
return false;
}
}

/**
Expand Down Expand Up @@ -108,4 +114,4 @@ public function getLogs(int $offset, int $limit): array
{
throw new Exception('Method not supported');
}
}
}

0 comments on commit 2b8cc40

Please sign in to comment.