Skip to content

Commit

Permalink
Google reCaptcha feature
Browse files Browse the repository at this point in the history
Signed-off-by: Shreyas Sinha <shreyas.sinha14@gmail.com>
  • Loading branch information
ShreyasSinha committed Feb 17, 2017
1 parent 3c5eaaf commit bd3461b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
22 changes: 22 additions & 0 deletions js/functions.js
Expand Up @@ -5022,6 +5022,28 @@ function toggleDatepickerIfInvalid($td, $input_field) {
}
}

/*
* Function to enable the 'Go' button on login.
*/
function captcha_enable() {
$('#input_go').prop('disabled', false);
}

/*
* Function to disable the 'Go' button on login.
*/
function captcha_disable() {
$('#input_go').prop('disabled', true);
}

/*
* Setting the 'Go' login button to disable by default.
*/
$(function ()
{
captcha_disable();
});

/**
* Unbind all event handlers before tearing down a page
*/
Expand Down
3 changes: 2 additions & 1 deletion libraries/plugins/auth/AuthenticationCookie.php
Expand Up @@ -228,7 +228,8 @@ public function auth()
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']) , '"></div>';
, htmlspecialchars($GLOBALS['cfg']['CaptchaLoginPublicKey']) ,
'" data-callback="captcha_enable" data-expired-callback="captcha_disable"></div>';
}

echo '</fieldset>
Expand Down
2 changes: 1 addition & 1 deletion test/classes/plugin/auth/AuthenticationCookieTest.php
Expand Up @@ -334,7 +334,7 @@ public function testAuthCaptcha()
);

$this->assertContains(
'<div class="g-recaptcha" data-sitekey="testpubkey">',
'<div class="g-recaptcha" data-sitekey="testpubkey" data-callback="captcha_enable" data-expired-callback="captcha_disable">',
$result
);
}
Expand Down

0 comments on commit bd3461b

Please sign in to comment.