Skip to content

Commit

Permalink
Merge pull request #1195 from plentymarkets/fix/recaptcha_consent
Browse files Browse the repository at this point in the history
add fallback
  • Loading branch information
stentrop authored Mar 27, 2024
2 parents 3c4535c + ec9fd84 commit ff12a35
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/Helper/ReCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,15 @@ public static function verify($token, $strict = false)

$secret = $templateConfigService->get('global.google_recaptcha_secret');
$blockCookies = $templateConfigService->getBoolean('global.block_cookies');
$isConsented = $consentRepository->isConsented('media.reCaptcha');
$isConsented = $consentRepository->isConsented('media.reCaptcha') || $consentRepository->isConsented('necessary.reCaptcha');

if ( !strlen( $secret ) )
{
if (!strlen($secret)) {
// No secret defined in config => skip reCAPTCHA validation
return true;
}
else if ($blockCookies && !$isConsented && !$strict)
{
} elseif ($blockCookies && !$isConsented && !$strict) {
// page has to operate without cookies
return true;
}
else if ( !strlen( $token ) )
{
} elseif (!strlen($token)) {
// reCAPTCHA is enabled by config but no token is given
return false;
}
Expand All @@ -59,8 +54,7 @@ public static function verify($token, $strict = false)

$ch = curl_init();

foreach($options as $option => $value)
{
foreach ($options as $option => $value) {
curl_setopt($ch, $option, $value);
}

Expand Down

0 comments on commit ff12a35

Please sign in to comment.