Magento 2 recaptcha module sometimes not working

Viewed 24

In our system we have Magento_ReCaptchaFrontendUi and for some reason when a customer creates a account he gets the "Something went wrong with reCAPTCHA. Please contact the store owner" message.

But I cant replicate that error, only other people at their office or some clients, for them sometimes it works in incognite aswell.

The issue is that I remotely connected to one pc that had this issue and the getTemplate was not working.I will share the code for whoever has this module.

The file : vendor/magento/module-re-captcha-frontend-ui/view/frontend/templates/recaptcha.phtml

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

/** @var $block \Magento\ReCaptchaUi\Block\ReCaptcha */
?>
<div
    class="field-recaptcha"
    id="<?= /* @noEscape */ $block->getRecaptchaId() ?>-container"
    data-bind="scope:'<?= /* @noEscape */ $block->getRecaptchaId() ?>'"
>
    <!-- ko template: getTemplate() --><!-- /ko -->
</div>

<script type="text/x-magento-init">
{
    "#<?= /* @noEscape */ $block->getRecaptchaId() ?>-container": {
        "Magento_Ui/js/core/app": <?= /* @noEscape */ $block->getJsLayout() ?>
    }
}
</script>


The getTemplate() would load the following html

vendor/magento/module-re-captcha-frontend-ui/view/frontend/web/template/reCaptcha.html

<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
 -->

<div data-bind="{
    attr: {
        'id': getReCaptchaId() + '-wrapper'
    },
    'afterRender': renderReCaptcha()
}">
    <div class="g-recaptcha"></div>
    <!-- ko if: (!getIsInvisibleRecaptcha()) -->
    <div class="field">
        <div class="control">
            <input type="checkbox"
                   value=""
                   class="required-captcha checkbox"
                   name="recaptcha-validate-"
                   data-validate="{required:true}"
                   tabindex="-1">
        </div>
    </div>
    <!-- /ko -->
</div>

If the second template is not loading then the error message will happend.

0 Answers
Related