Skip to content

Commit

Permalink
store lastScore
Browse files Browse the repository at this point in the history
  • Loading branch information
usamamuneerchaudhary committed Mar 4, 2024
1 parent 741e0c0 commit 71202f2
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/HCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ class HCaptcha
* @var array
*/
protected $verifiedResponses = [];


/**
* @var null
* lastScore
*/
protected $lastScore = null;


/**
* HCaptcha.
*
Expand Down Expand Up @@ -140,6 +147,7 @@ public function verifyResponse($response, $clientIp = null)
]);

if (isset($verifyResponse['success']) && $verifyResponse['success'] === true) {
$this->lastScore = isset($verifyResponse['score']) ? $verifyResponse['score'] : null;
// Check score if it's enabled.
$isScoreVerificationEnabled = config('HCaptcha.score_verification_enabled', false);

Expand Down Expand Up @@ -194,6 +202,16 @@ public function getJsLink($lang = null, $callback = false, $onLoadClass = 'onloa

return $client_api . '?' . http_build_query($params);
}

/**
* Get the score from the last successful hCaptcha verification.
*
* @return float|null The score of the last verification or null if not available.
*/
public function getScoreFromLastVerification()
{
return $this->lastScore;
}

/**
* @param $params
Expand Down

0 comments on commit 71202f2

Please sign in to comment.