From ec9fd8438d8bf7166817a66c614f0095deaed6bf Mon Sep 17 00:00:00 2001 From: Steve Tentrop Date: Wed, 27 Mar 2024 11:20:28 +0100 Subject: [PATCH] add fallback --- src/Helper/ReCaptcha.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Helper/ReCaptcha.php b/src/Helper/ReCaptcha.php index 73c24ed67..4bc0ce7d3 100644 --- a/src/Helper/ReCaptcha.php +++ b/src/Helper/ReCaptcha.php @@ -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; } @@ -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); }