Skip to content

Commit

Permalink
Merge pull request #79 from WoW-CMS/71-bug-report-recaptcha-mail-veri…
Browse files Browse the repository at this point in the history
…fication-not-working-getting-bombed

71 bug report recaptcha mail verification not working getting bombed
  • Loading branch information
sayghteight authored Sep 23, 2022
2 parents ce94743 + 0ce841e commit 1150755
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
8 changes: 8 additions & 0 deletions application/config/blizzcms.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@
*/
$config['recaptcha_secretkey'] = '';

/**
*
* Puntuation Score
* 0.5 Default Puntuation score, more information in @ https://developers.google.com/recaptcha/docs/v3
*
*/
$config['score_puntuation'] = '0.5';

/**
*
* SMTP
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/recaptcha_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

defined('RECAPTCHA_SITE_KEY') OR define('RECAPTCHA_SITE_KEY', $CI->config->item('recaptcha_sitekey'));
defined('RECAPTCHA_SITE_SECRET') OR define('RECAPTCHA_SITE_SECRET', $CI->config->item('recaptcha_secretkey'));
defined('RECAPTCHA_ACCEPTABLE_SPAM_SCORE') OR define('RECAPTCHA_ACCEPTABLE_SPAM_SCORE', 0.5);
defined('RECAPTCHA_ACCEPTABLE_SPAM_SCORE') OR define('RECAPTCHA_ACCEPTABLE_SPAM_SCORE', $CI->config->item('score_puntuation'));


if(!function_exists('get_recapture_score')) {
Expand Down
16 changes: 10 additions & 6 deletions application/modules/user/controllers/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ public function register()
$password = $this->input->post('password');
$emulator = $this->config->item('emulator');

$score = get_recapture_score($this->input->post('g-recaptcha-response'));

if (!$this->wowauth->account_unique($username, 'username'))
{
Expand All @@ -207,11 +206,16 @@ public function register()
return false;
}

if($score < RECAPTCHA_ACCEPTABLE_SPAM_SCORE){
$data['msg_notification_used_email'] = 'A low score has been detected when registering an account on our site.';
$this->template->build('register', $data);
return false;
}
if ($this->wowmodule->getreCaptchaStatus())
{
$score = get_recapture_score($this->input->post('g-recaptcha-response'));

if($score < RECAPTCHA_ACCEPTABLE_SPAM_SCORE){
$data['msg_notification_used_email'] = 'A low score has been detected when registering an account on our site.';
$this->template->build('register', $data);
return false;
}
}

$register = $this->user_model->insertRegister($username, $email, $password, $emulator);

Expand Down
19 changes: 10 additions & 9 deletions application/themes/default/views/layouts/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
<script src="<?= $template['assets'].'core/uikit/js/uikit.min.js'; ?>"></script>
<script src="<?= $template['assets'].'core/uikit/js/uikit-icons.min.js'; ?>"></script>
<!-- ReCaptcha v3 Google API -->
<script src="https://www.google.com/recaptcha/api.js?render=<?php echo RECAPTCHA_SITE_KEY; ?>"></script>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('<?php echo RECAPTCHA_SITE_KEY; ?>', {action: 'form_submission'}).then(function(token) {
document.querySelector('.g-recaptcha-response').value = token;
});
});
</script>

<?php if ($this->wowmodule->getreCaptchaStatus()) { ?>
<script src="https://www.google.com/recaptcha/api.js?render=<?php echo RECAPTCHA_SITE_KEY; ?>"></script>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('<?php echo RECAPTCHA_SITE_KEY; ?>', {action: 'form_submission'}).then(function(token) {
document.querySelector('.g-recaptcha-response').value = token;
});
});
</script>
<?php } ?>
</head>
<body>
<div class="uk-navbar-container uk-navbar-transparent">
Expand Down

0 comments on commit 1150755

Please sign in to comment.