From a9941dea8a0d7a947ddf36eb5335195393cb3123 Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 29 Aug 2022 19:04:47 +0200 Subject: [PATCH] Fixes --- config.php | 4 ++-- system/libs/GoogleReCAPTCHA.php | 24 +++++++++------------ system/templates/templates.header.html.twig | 4 ++-- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/config.php b/config.php index bd8483bf..36eda984 100644 --- a/config.php +++ b/config.php @@ -135,13 +135,13 @@ $config = array( 'smtp_secure' => '', // What kind of encryption to use on the SMTP connection. Options: '', 'ssl' (GMail) or 'tls' (Microsoft Outlook) 'smtp_debug' => false, // set true to debug (you will see more info in error.log) - // reCAPTCHA v3 (prevent spam bots) + // Google reCAPTCHA v3 (prevent spam bots) 'recaptcha_enabled' => false, // enable recaptcha verification code 'recaptcha_site_key' => '', // get your own site and secret keys at https://www.google.com/recaptcha 'recaptcha_secret_key' => '', // min score for validation, between 0 - 1.0 // https://developers.google.com/recaptcha/docs/v3#interpreting_the_score - 'recaptcha_v3_min_score' => 0.5, + 'recaptcha_min_score' => 0.5, // 'generate_new_reckey' => true, // let player generate new recovery key, he will receive e-mail with new rec key (not display on page, hacker can't generate rec key) diff --git a/system/libs/GoogleReCAPTCHA.php b/system/libs/GoogleReCAPTCHA.php index d1799619..fe4bda0a 100644 --- a/system/libs/GoogleReCAPTCHA.php +++ b/system/libs/GoogleReCAPTCHA.php @@ -41,21 +41,17 @@ 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; + } - $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->score) || $json->score < config('recaptcha_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/templates.header.html.twig b/system/templates/templates.header.html.twig index 6438076a..d6ae1fbb 100644 --- a/system/templates/templates.header.html.twig +++ b/system/templates/templates.header.html.twig @@ -17,5 +17,5 @@ {% if config.recaptcha_enabled %} - -{% endif %} \ No newline at end of file + +{% endif %}