Merge pull request #13101 from manishbisht/google-recaptcha-upgrade

upgraded google recpatcha with google invisble recaptcha
This commit is contained in:
Michal Čihař 2017-06-28 12:03:57 +03:00 committed by GitHub
commit daf44c8d1e
3 changed files with 22 additions and 28 deletions

View File

@ -5012,17 +5012,10 @@ function toggleDatepickerIfInvalid($td, $input_field) {
}
/*
* Function to enable the 'Go' button on login.
* Function to submit the login form after validation is done.
*/
function loginButtonEnable() {
$('#input_go').prop('disabled', false);
}
/*
* Function to disable the 'Go' button on login.
*/
function loginButtonDisable() {
$('#input_go').prop('disabled', true);
function recaptchaCallback() {
$('#login_form').submit();
}
/**

View File

@ -172,7 +172,7 @@ class AuthenticationCookie extends AuthenticationPlugin
echo '
<br />
<!-- Login form -->
<form method="post" action="index.php" name="login_form"' , $autocomplete ,
<form method="post" id="login_form" action="index.php" name="login_form"' , $autocomplete ,
' class="disableAjax login hide js-show">
<fieldset>
<legend>';
@ -228,21 +228,21 @@ class AuthenticationCookie extends AuthenticationPlugin
, $GLOBALS['server'] , '" />';
} // end if (server choice)
// Add captcha input field if reCaptcha is enabled
if (!empty($GLOBALS['cfg']['CaptchaLoginPrivateKey'])
&& !empty($GLOBALS['cfg']['CaptchaLoginPublicKey'])
) {
// If enabled show captcha to the user on the login screen.
echo '<script src="https://www.google.com/recaptcha/api.js?hl='
, $GLOBALS['lang'] , '" async defer></script>';
echo '<div class="g-recaptcha" data-sitekey="'
, htmlspecialchars($GLOBALS['cfg']['CaptchaLoginPublicKey']) ,
'" data-callback="loginButtonEnable" data-expired-callback="loginButtonDisable" captcha="enabled"></div>';
}
echo '</fieldset><fieldset class="tblFooters">';
echo '</fieldset>
<fieldset class="tblFooters">
<input value="' , __('Go') , '" type="submit" id="input_go" />';
// binds input field with invisible reCaptcha if enabled
if (empty($GLOBALS['cfg']['CaptchaLoginPrivateKey'])
&& empty($GLOBALS['cfg']['CaptchaLoginPublicKey'])
) {
echo '<input value="' , __('Go') , '" type="submit" id="input_go" />';
}
else {
echo '<script src="https://www.google.com/recaptcha/api.js?hl='
, $GLOBALS['lang'] , '" async defer></script>';
echo '<input class="g-recaptcha" data-sitekey="'
, htmlspecialchars($GLOBALS['cfg']['CaptchaLoginPublicKey']),'"'
.' data-callback="recaptchaCallback" value="' , __('Go') , '" type="submit" id="input_go" />';
}
$_form_params = array();
if (! empty($GLOBALS['target'])) {
$_form_params['target'] = $GLOBALS['target'];

View File

@ -209,7 +209,7 @@ class AuthenticationCookieTest extends PMATestCase
);
$this->assertContains(
'<form method="post" action="index.php" name="login_form" ' .
'<form method="post" id="login_form" action="index.php" name="login_form" ' .
'class="disableAjax login hide js-show">',
$result
);
@ -317,7 +317,7 @@ class AuthenticationCookieTest extends PMATestCase
}
$this->assertContains(
'<form method="post" action="index.php" name="login_form" ' .
'<form method="post" id="login_form" action="index.php" name="login_form" ' .
'autocomplete="off" class="disableAjax login hide js-show">',
$result
);
@ -334,7 +334,8 @@ class AuthenticationCookieTest extends PMATestCase
);
$this->assertContains(
'<div class="g-recaptcha" data-sitekey="testpubkey" data-callback="loginButtonEnable" data-expired-callback="loginButtonDisable" captcha="enabled">',
'<input class="g-recaptcha" data-sitekey="testpubkey"'
. ' data-callback="recaptchaCallback" value="Go" type="submit" id="input_go" />',
$result
);
}