Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions core/modules/security/captcha/modCaptchaGooglerecaptcha.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

/**
* \file htdocs/core/modules/security/captcha/modCaptchaEasytooltip.class.php
* \file htdocs/core/modules/security/captcha/modCaptchaGooglerecaptcha.class.php
* \ingroup core
* \brief File to manage captcha generation according to dolibarr native code
*/
Expand Down Expand Up @@ -71,7 +71,7 @@ public function __construct($db, $conf, $langs, $user)
public function getDescription()
{
global $langs;
return $langs->trans("DolibarrEasytooltipCaptcha");
return $langs->trans("DolibarrGoogleRecaptchaCaptcha");
}

/**
Expand All @@ -81,8 +81,6 @@ public function getDescription()
*/
public function getExample()
{
global $db, $langs, $user;

$out = '<script src="https://www.google.com/recaptcha/api.js?render=' . getDolGlobalString('GOOGLERECAPTCHA_SITE_KEY') . '"></script>';
$out .= "<script>\n";
$out .= "$('#login').submit(function() {\n";
Expand Down Expand Up @@ -110,25 +108,7 @@ public function getExample()
*/
public function getCaptchaCodeForForm($php_self = '')
{
global $langs;

$out = '<script src="https://www.google.com/recaptcha/api.js?render=' . getDolGlobalString('GOOGLERECAPTCHA_SITE_KEY') . '"></script>';
$out .= "<script>\n";
$out .= "$('#login').submit(function() {\n";
$out .= " // we stoped it\n";
$out .= " event.preventDefault();\n";
$out .= " console.log('try login...');\n";
$out .= " grecaptcha.ready(function() {\n";
$out .= " grecaptcha.execute('" . getDolGlobalString('GOOGLERECAPTCHA_SITE_KEY') . "', {action: 'login'}).then(function(token) {\n";
$out .= " // add token to form\n";
$out .= " $('#login').prepend('<input type=\"hidden\" name=\"g-recaptcha-response\" value=\"' + token + '\">');\n";
$out .= " $('#login').unbind('submit').submit();\n";
$out .= " });\n";
$out .= " });\n";
$out .= "});\n";
$out .= "</script>\n";

return $out;
return $this->getExample();
}


Expand Down
1 change: 1 addition & 0 deletions langs/fr_FR/googlerecaptcha.lang
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ ValidScore=Validé avec un score de %s (Valeur comprise entre 0 et 1)
#
GoogleRecaptchaAbout=À propos de GoogleRecaptcha
GoogleRecaptchaAboutPage=Page à propos de GoogleRecaptcha
DolibarrGoogleRecaptchaCaptcha=Recaptcha Google pour Dolibarr
Loading