mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 09:19:22 +02:00
Fixes for racaptcha
This commit is contained in:
parent
c73e476e88
commit
118e8c487e
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -120,7 +120,7 @@
|
||||
<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>
|
||||
<div class="g-recaptcha" data-sitekey="{{ config.recaptcha_site_key }}" data-theme="{{ config.recaptcha_v2_theme }}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
{% if errors.verification is defined %}
|
||||
|
@ -50,7 +50,7 @@ Please enter your account {{ account|lower }} and your password.<br/><a href="?s
|
||||
<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>
|
||||
<div class="g-recaptcha" data-sitekey="{{ config.recaptcha_site_key }}" data-theme="{{ config.recaptcha_v2_theme }}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
@ -93,4 +93,4 @@ Please enter your account {{ account|lower }} and your password.<br/><a href="?s
|
||||
{% if config.recaptcha_enabled and config.recaptcha_type == 'v3' %}
|
||||
{% set action = 'login' %}
|
||||
{{ include('google_recaptcha_v3.html.twig') }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
@ -17,5 +17,5 @@
|
||||
</div>
|
||||
</noscript>
|
||||
{% if config.recaptcha_enabled %}
|
||||
<script src="https://www.google.com/recaptcha/api.js?render={{ config.recaptcha_site_key }}"></script>
|
||||
<script src="https://www.google.com/recaptcha/api.js{% if config('recaptcha_type') === 'v2-checkbox' %}?render={{ config.recaptcha_site_key }}{% endif %}"></script>
|
||||
{% endif %}
|
||||
|
@ -58,7 +58,7 @@
|
||||
<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>
|
||||
<div class="g-recaptcha" data-sitekey="{{ config.recaptcha_site_key }}" data-theme="{{ config.recaptcha_v2_theme }}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
@ -163,4 +163,4 @@
|
||||
{% if config.recaptcha_enabled and config.recaptcha_type == 'v3' %}
|
||||
{% set action = 'login' %}
|
||||
{{ include('google_recaptcha_v3.html.twig') }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user