Lets support only ReCaptcha v3

Too much mess ;)
This commit is contained in:
slawkens 2022-08-28 18:13:34 +02:00
parent fd51fa7779
commit 87a98531d9
6 changed files with 13 additions and 59 deletions

View File

@ -125,14 +125,10 @@ $config = array(
'smtp_secure' => '', // What kind of encryption to use on the SMTP connection. Options: '', 'ssl' (GMail) or 'tls' (Microsoft Outlook) '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) 'smtp_debug' => false, // set true to debug (you will see more info in error.log)
// reCAPTCHA (prevent spam bots) // reCAPTCHA v3 (prevent spam bots)
'recaptcha_enabled' => false, // enable recaptcha verification code '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_site_key' => '', // get your own site and secret keys at https://www.google.com/recaptcha
'recaptcha_secret_key' => '', 'recaptcha_secret_key' => '',
// following option apply only for ReCaptcha v2-checkbox
'recaptcha_theme' => 'light', // light, dark
// following option apply only for ReCaptcha v3
// min score for validation, between 0 - 1.0 // min score for validation, between 0 - 1.0
// https://developers.google.com/recaptcha/docs/v3#interpreting_the_score // https://developers.google.com/recaptcha/docs/v3#interpreting_the_score
'recaptcha_v3_min_score' => 0.5, 'recaptcha_v3_min_score' => 0.5,

View File

@ -497,7 +497,7 @@ function template_header($is_admin = false)
'; ';
if(config('recaptcha_enabled')) { if(config('recaptcha_enabled')) {
$ret .= '<script src="https://www.google.com/recaptcha/api.js' . (config('recaptcha_type') === 'v2-checkbox' ? '' : '?render=' . config('recaptcha_site_key')) . '"></script>'; $ret .= '<script src="https://www.google.com/recaptcha/api.js?render=' . config('recaptcha_site_key') . '"></script>';
} }
return $ret; return $ret;

View File

@ -105,23 +105,7 @@
{{ hook('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS') }} {{ hook('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS') }}
{% if config.recaptcha_enabled %} {% if config.recaptcha_enabled %}
{% if config.recaptcha_type == 'v3' %} <input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response" />
<input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response" />
{% elseif config.recaptcha_type == 'v2-invisible' %}
<div class="g-recaptcha" data-sitekey="{{ config.recaptcha_site_key }}" data-bind="login-submit"></div>
{% elseif config.recaptcha_type == 'v2-checkbox' %}
<tr>
<td class="LabelV" style="width: 150px">
<span{% if errors.verification[0] is not null %} class="red"{% endif %}>Verification:</span>
</td>
<td>
<div class="g-recaptcha" data-sitekey="{{ config.recaptcha_site_key }}" data-theme="{{ config.recaptcha_theme }}"></div>
</td>
</tr>
{% if errors.verification is defined %}
<tr><td></td><td><span class="FormFieldError">{{ errors.verification }}</span></td></tr>
{% endif %}
{% endif %}
{% endif %} {% endif %}
{{ hook('HOOK_ACCOUNT_CREATE_AFTER_RECAPTCHA') }} {{ hook('HOOK_ACCOUNT_CREATE_AFTER_RECAPTCHA') }}
@ -340,7 +324,7 @@
</form> </form>
{{ hook('HOOK_ACCOUNT_CREATE_AFTER_FORM') }} {{ hook('HOOK_ACCOUNT_CREATE_AFTER_FORM') }}
<script type="text/javascript" src="tools/check_name.js"></script> <script type="text/javascript" src="tools/check_name.js"></script>
{% if config.recaptcha_enabled and config.recaptcha_type == 'v3' %} {% if config.recaptcha_enabled %}
{% set action = 'register' %} {% set action = 'register' %}
{{ include('google_recaptcha_v3.html.twig') }} {{ include('google_recaptcha.html.twig') }}
{% endif %} {% endif %}

View File

@ -40,20 +40,7 @@ Please enter your account {{ account|lower }} and your password.<br/><a href="?s
<label for="remember_me"> Remember me</label></td> <label for="remember_me"> Remember me</label></td>
</tr> </tr>
{% if config.recaptcha_enabled %} {% if config.recaptcha_enabled %}
{% if config.recaptcha_type == 'v3' %}
<input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response" /> <input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response" />
{% elseif config.recaptcha_type == 'v2-invisible' %}
<div class="g-recaptcha" data-sitekey="{{ config.recaptcha_site_key }}" data-bind="login-submit"></div>
{% elseif config.recaptcha_type == 'v2-checkbox' %}
<tr>
<td class="LabelV" style="width: 150px">
<span{% if error is not null %} class="red"{% endif %}>Verification:</span>
</td>
<td>
<div class="g-recaptcha" data-sitekey="{{ config.recaptcha_site_key }}" data-theme="{{ config.recaptcha_theme }}"></div>
</td>
</tr>
{% endif %}
{% endif %} {% endif %}
{% if error is not null %} {% if error is not null %}
<tr><td></td><td><span class="FormFieldError">{{ error }}</span></td></tr> <tr><td></td><td><span class="FormFieldError">{{ error }}</span></td></tr>
@ -90,7 +77,7 @@ Please enter your account {{ account|lower }} and your password.<br/><a href="?s
</td> </td>
</tr> </tr>
</table> </table>
{% if config.recaptcha_enabled and config.recaptcha_type == 'v3' %} {% if config.recaptcha_enabled %}
{% set action = 'login' %} {% set action = 'login' %}
{{ include('google_recaptcha_v3.html.twig') }} {{ include('google_recaptcha.html.twig') }}
{% endif %} {% endif %}

View File

@ -46,20 +46,7 @@
<label for="remember_me"> Remember me</label></td> <label for="remember_me"> Remember me</label></td>
</tr> </tr>
{% if config.recaptcha_enabled %} {% if config.recaptcha_enabled %}
{% if config.recaptcha_type == 'v3' %} <input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response" />
<input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response" />
{% elseif config.recaptcha_type == 'v2-invisible' %}
<div class="g-recaptcha" data-sitekey="{{ config.recaptcha_site_key }}" data-bind="login-submit"></div>
{% elseif config.recaptcha_type == 'v2-checkbox' %}
<tr>
<td class="LabelV" style="width: 150px">
<span{% if error is not null %} class="red"{% endif %}>Verification:</span>
</td>
<td>
<div class="g-recaptcha" data-sitekey="{{ config.recaptcha_site_key }}" data-theme="{{ config.recaptcha_theme }}"></div>
</td>
</tr>
{% endif %}
{% endif %} {% endif %}
</table> </table>
<div style="float: right; font-size: 1px;" > <div style="float: right; font-size: 1px;" >
@ -158,7 +145,7 @@
</tr> </tr>
</table> </table>
</div> </div>
{% if config.recaptcha_enabled and config.recaptcha_type == 'v3' %} {% if config.recaptcha_enabled %}
{% set action = 'login' %} {% set action = 'login' %}
{{ include('google_recaptcha_v3.html.twig') }} {{ include('google_recaptcha.html.twig') }}
{% endif %} {% endif %}