diff --git a/config.php b/config.php index 4f4d4c5a..50f42d66 100644 --- a/config.php +++ b/config.php @@ -135,13 +135,17 @@ $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) - // Google reCAPTCHA v3 (prevent spam bots) + // Google reCAPTCHA (prevent spam bots) 'recaptcha_enabled' => false, // enable recaptcha verification code + 'recaptcha_type' => 'v3', // 'v2-checkbox', 'v2-invisible', 'v3' '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_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 - 'recaptcha_min_score' => 0.5, + 'recaptcha_v3_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/get_version_for_release.php b/system/get_version_for_release.php index fa378dbb..c4070d4d 100644 --- a/system/get_version_for_release.php +++ b/system/get_version_for_release.php @@ -1,4 +1,6 @@ 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 6b60207f..b5dfc2e2 100644 --- a/system/templates/account.create.html.twig +++ b/system/templates/account.create.html.twig @@ -109,8 +109,24 @@ {{ hook('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS') }} - {% if config.recaptcha_enabled %} - + {% if config.recaptcha_enabled %} + {% if config.recaptcha_type == 'v3' %} + + {% elseif config.recaptcha_type == 'v2-invisible' %} +
+ {% elseif config.recaptcha_type == 'v2-checkbox' %} + + + Verification: + + +
+ + + {% if errors.verification is defined %} + {{ errors.verification }} + {% endif %} + {% endif %} {% endif %} {{ hook('HOOK_ACCOUNT_CREATE_AFTER_RECAPTCHA') }} @@ -329,9 +345,9 @@ {{ hook('HOOK_ACCOUNT_CREATE_AFTER_FORM') }} -{% if config.recaptcha_enabled %} +{% if config.recaptcha_enabled and config.recaptcha_type == 'v3' %} {% set action = 'register' %} - {{ include('google_recaptcha.html.twig') }} + {{ include('google_recaptcha_v3.html.twig') }} {% endif %}