Skip to content

Commit

Permalink
try-catch around recaptcha->verify()
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebagwell committed Oct 18, 2022
1 parent 8cc207c commit 4162204
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion application/common/helpers/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ public static function getRandomDigits($length = 4)
public static function isRecaptchaResponseValid($verificationToken, $ipAddress)
{
$recaptcha = new ReCaptcha(\Yii::$app->params['recaptcha']['secretKey'], new ReCaptchaCurlPost());
$response = $recaptcha->verify($verificationToken, $ipAddress);

try {
$response = $recaptcha->verify($verificationToken, $ipAddress);
} catch (\Exception $e) {
throw new \Exception('Error attempting to verify recaptcha token: ' . $e->getMessage(), 1666090198);
}

if ($response->isSuccess()) {
return true;
Expand Down

0 comments on commit 4162204

Please sign in to comment.