mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-22 16:40:21 +01:00
Merge pull request #5135 from senky/ticket/15564
[ticket/15564] Switch to Invisible reCAPTCHA
This commit is contained in:
commit
36614e6f81
@ -5,8 +5,9 @@
|
||||
<div>{L_RECAPTCHA_NOSCRIPT}</div>
|
||||
</noscript>
|
||||
|
||||
{L_RECAPTCHA_INVISIBLE}
|
||||
<script src="{RECAPTCHA_SERVER}.js?hl={LA_RECAPTCHA_LANG}" async defer></script>
|
||||
<div class="g-recaptcha" data-sitekey="{RECAPTCHA_PUBKEY}"></div>
|
||||
<div class="g-recaptcha" data-sitekey="{RECAPTCHA_PUBKEY}" data-size="invisible"></div>
|
||||
</dd>
|
||||
</dl>
|
||||
<!-- ELSE -->
|
||||
|
@ -1650,6 +1650,50 @@ phpbb.lazyLoadAvatars = function loadAvatars() {
|
||||
});
|
||||
};
|
||||
|
||||
var recaptchaForm = $('.g-recaptcha').parents('form');
|
||||
var submitButton = null;
|
||||
var programaticallySubmitted = false;
|
||||
|
||||
phpbb.recaptchaOnLoad = function () {
|
||||
// Listen to submit buttons in order to know which one was pressed
|
||||
$('input[type="submit"]').each(function () {
|
||||
$(this).on('click', function () {
|
||||
submitButton = this;
|
||||
});
|
||||
});
|
||||
|
||||
recaptchaForm.on('submit', function (e) {
|
||||
if (!programaticallySubmitted) {
|
||||
grecaptcha.execute();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
phpbb.recaptchaOnSubmit = function () {
|
||||
programaticallySubmitted = true;
|
||||
// If concrete button was clicked (e.g. preview instead of submit),
|
||||
// let's trigger the same action
|
||||
if (submitButton) {
|
||||
submitButton.click();
|
||||
} else {
|
||||
// Rename input[name="submit"] so that we can submit the form
|
||||
if (typeof recaptchaForm.submit !== 'function') {
|
||||
recaptchaForm.submit.name = 'submit_btn';
|
||||
}
|
||||
recaptchaForm.submit();
|
||||
}
|
||||
}
|
||||
|
||||
// reCAPTCHA doesn't accept callback functions nested inside objects
|
||||
// so we need to make this helper functions here
|
||||
window.phpbbRecaptchaOnLoad = function() {
|
||||
phpbb.recaptchaOnLoad();
|
||||
}
|
||||
window.phpbbRecaptchaOnSubmit = function() {
|
||||
phpbb.recaptchaOnSubmit();
|
||||
}
|
||||
|
||||
$(window).on('load', phpbb.lazyLoadAvatars);
|
||||
|
||||
/**
|
||||
|
@ -43,10 +43,10 @@ $lang = array_merge($lang, array(
|
||||
'RECAPTCHA_INCORRECT' => 'The solution you provided was incorrect',
|
||||
'RECAPTCHA_NOSCRIPT' => 'Please enable JavaScript in your browser to load the challenge.',
|
||||
|
||||
'RECAPTCHA_PUBLIC' => 'Public reCaptcha key',
|
||||
'RECAPTCHA_PUBLIC_EXPLAIN' => 'Your public reCaptcha key. Keys can be obtained on <a href="http://www.google.com/recaptcha">www.google.com/recaptcha</a>.',
|
||||
'RECAPTCHA_PRIVATE' => 'Private reCaptcha key',
|
||||
'RECAPTCHA_PRIVATE_EXPLAIN' => 'Your private reCaptcha key. Keys can be obtained on <a href="http://www.google.com/recaptcha">www.google.com/recaptcha</a>.',
|
||||
'RECAPTCHA_PUBLIC' => 'Site key',
|
||||
'RECAPTCHA_PUBLIC_EXPLAIN' => 'Your site reCAPTCHA key. Keys can be obtained on <a href="http://www.google.com/recaptcha">www.google.com/recaptcha</a>. Please, use reCAPTCHA v2 > Invisible reCAPTCHA badge type.',
|
||||
'RECAPTCHA_PRIVATE' => 'Secret key',
|
||||
'RECAPTCHA_PRIVATE_EXPLAIN' => 'Your secret reCAPTCHA key. Keys can be obtained on <a href="http://www.google.com/recaptcha">www.google.com/recaptcha</a>. Please, use reCAPTCHA v2 > Invisible reCAPTCHA badge type.',
|
||||
|
||||
'RECAPTCHA_EXPLAIN' => 'In an effort to prevent automatic submissions, we require that you complete the following challenge.',
|
||||
'RECAPTCHA_INVISIBLE' => 'This CAPTCHA is actually invisible. To verify that it works, a small icon should appear in right bottom corner of this page.',
|
||||
));
|
||||
|
@ -392,7 +392,7 @@ $lang = array_merge($lang, array(
|
||||
'LOGIN_CHECK_PM' => 'Log in to check your private messages.',
|
||||
'LOGIN_CONFIRMATION' => 'Confirmation of login',
|
||||
'LOGIN_CONFIRM_EXPLAIN' => 'To prevent brute forcing accounts the board requires you to enter a confirmation code after a maximum amount of failed logins. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.', // unused
|
||||
'LOGIN_ERROR_ATTEMPTS' => 'You exceeded the maximum allowed number of login attempts. In addition to your username and password you now also have to solve the CAPTCHA below.',
|
||||
'LOGIN_ERROR_ATTEMPTS' => 'You exceeded the maximum allowed number of login attempts. In addition to your username and password you now also have to pass the CAPTCHA test.',
|
||||
'LOGIN_ERROR_EXTERNAL_AUTH_APACHE' => 'You have not been authenticated by Apache.',
|
||||
'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST' => 'A non-existant OAuth service has been requested.',
|
||||
'LOGIN_ERROR_PASSWORD' => 'You have specified an incorrect password. Please check your password and try again. If you continue to have problems please contact the %sBoard Administrator%s.',
|
||||
|
@ -1,30 +1,9 @@
|
||||
<!-- IF S_TYPE == 1 -->
|
||||
<div class="panel captcha-panel">
|
||||
<div class="inner">
|
||||
|
||||
<h3 class="captcha-title">{L_CONFIRMATION}</h3>
|
||||
<p>{L_CONFIRM_EXPLAIN}</p>
|
||||
|
||||
<fieldset class="fields2">
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF S_RECAPTCHA_AVAILABLE -->
|
||||
<dl>
|
||||
<dt><label>{L_CONFIRM_CODE}{L_COLON}</label><br /><span>{L_RECAPTCHA_EXPLAIN}</span></dt>
|
||||
<dd class="captcha">
|
||||
<noscript>
|
||||
<div>{L_RECAPTCHA_NOSCRIPT}</div>
|
||||
</noscript>
|
||||
<script src="{RECAPTCHA_SERVER}.js?hl={LA_RECAPTCHA_LANG}" async defer></script>
|
||||
<div class="g-recaptcha" data-sitekey="{RECAPTCHA_PUBKEY}" data-tabindex="<!-- IF $CAPTCHA_TAB_INDEX -->{$CAPTCHA_TAB_INDEX}<!-- ELSE -->10<!-- ENDIF -->"></div>
|
||||
</dd>
|
||||
</dl>
|
||||
<noscript>
|
||||
<div>{L_RECAPTCHA_NOSCRIPT}</div>
|
||||
</noscript>
|
||||
{% INCLUDEJS RECAPTCHA_SERVER ~ '.js?onload=phpbbRecaptchaOnLoad&hl=' ~ lang('RECAPTCHA_LANG') %}
|
||||
<div class="g-recaptcha" data-sitekey="{RECAPTCHA_PUBKEY}" data-callback="phpbbRecaptchaOnSubmit" data-size="invisible" data-tabindex="<!-- IF $CAPTCHA_TAB_INDEX -->{$CAPTCHA_TAB_INDEX}<!-- ELSE -->10<!-- ENDIF -->"></div>
|
||||
<!-- ELSE -->
|
||||
{L_RECAPTCHA_NOT_AVAILABLE}
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF S_TYPE == 1 -->
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ENDIF -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user