diff --git a/config.php b/config.php index 5f6d7706..73fbc2af 100644 --- a/config.php +++ b/config.php @@ -141,7 +141,7 @@ $config = array( 'recaptcha_site_key' => '', // get your own site and secret keys at https://www.google.com/recaptcha 'recaptcha_secret_key' => '', // following option apply only for ReCaptcha v2-checkbox - 'recaptcha_theme' => 'light', // light, dark + 'recaptcha_v2_theme' => 'light', // light, dark // following option apply only for ReCaptcha v3 // min score for validation, between 0 - 1.0 // https://developers.google.com/recaptcha/docs/v3#interpreting_the_score diff --git a/system/libs/GoogleReCAPTCHA.php b/system/libs/GoogleReCAPTCHA.php index fe4bda0a..3dd18b28 100644 --- a/system/libs/GoogleReCAPTCHA.php +++ b/system/libs/GoogleReCAPTCHA.php @@ -41,17 +41,22 @@ class GoogleReCAPTCHA } $json = json_decode($response); - //log_append('recaptcha.log', 'recaptcha_score: ' . $json->score . ', action:' . $json->action); - if (!isset($json->action) || $json->action !== $action) { - self::$errorType = self::ERROR_INVALID_ACTION; - self::$errorMessage = 'Google ReCaptcha returned invalid action.'; - return false; - } - if (!isset($json->score) || $json->score < config('recaptcha_min_score')) { - self::$errorType = self::ERROR_LOW_SCORE; - self::$errorMessage = 'Your Google ReCaptcha score was too low.'; - return false; + $recaptchaType = config('recaptcha_type'); + if ($recaptchaType === 'v3') { // score based + //log_append('recaptcha.log', 'recaptcha_score: ' . $json->score . ', action:' . $json->action); + + if (!isset($json->action) || $json->action !== $action) { + self::$errorType = self::ERROR_INVALID_ACTION; + self::$errorMessage = 'Google ReCaptcha returned invalid action.'; + return false; + } + + if (!isset($json->score) || $json->score < config('recaptcha_v3_min_score')) { + self::$errorType = self::ERROR_LOW_SCORE; + self::$errorMessage = 'Your Google ReCaptcha score was too low.'; + return false; + } } if (!isset($json->success) || !$json->success) { diff --git a/system/templates/account.create.html.twig b/system/templates/account.create.html.twig index b08ba42d..a33fec59 100644 --- a/system/templates/account.create.html.twig +++ b/system/templates/account.create.html.twig @@ -120,7 +120,7 @@ Verification: