![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-re-captcha-user/view/adminhtml/templates/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ /** @var $block Magento\ReCaptchaUi\Block\ReCaptcha */ $config = $block->getCaptchaUiConfig(); $renderingOptions = $config['rendering'] ?? []; $isInvisible = !empty($config['invisible']); ?> <div class="admin__field <?= /* @noEscape */ $isInvisible ? 'field-invisible-recaptcha' : 'field-recaptcha' ?>"> <div id="admin-recaptcha" class="admin-recaptcha-content<?= /* @noEscape */ !empty($renderingOptions['size']) ? ' size-' . $renderingOptions['size'] : '' ?>"></div> </div> <script> require([ 'jquery' ], function ( $ ) { const element = document.createElement('script'); const scriptTag = document.getElementsByTagName('script')[0]; element.async = true; element.src = 'https://www.google.com/recaptcha/api.js' + '?onload=globalOnRecaptchaOnLoadCallback&render=explicit'; let isRecaptchaLoaded = false; let token = ''; let maxRetryAttempts = 5; let attempts = 0; let widgetId = 0; <?php if ($isInvisible): ?> $('#login-form').submit(function (event) { if (!token) { event.preventDefault(event); event.stopImmediatePropagation(); event.stopPropagation(); let attemptRecaptcha = () => { attempts++; if (attempts > maxRetryAttempts){ console.error("Could not fetch invisible ReCaptcha token. Please refresh the page."); return; } if (!isRecaptchaLoaded) { setTimeout(() => { attemptRecaptcha() }, 1000); return; } grecaptcha.execute(widgetId) .then( () => { event.preventDefault(event); event.stopImmediatePropagation(); event.stopPropagation(); }, (reason) => { }) .catch(err => { console.error(err); }); } attemptRecaptcha(); } }); <?php endif; ?> window.globalOnRecaptchaOnLoadCallback = function () { widgetId = grecaptcha.render('admin-recaptcha', { <?php foreach ($renderingOptions as $key => $value): ?> '<?= $block->escapeJs($key) ?>': '<?= $block->escapeJs($value) ?>', <?php endforeach; ?> 'callback': function (_token) { <?php if ($isInvisible): ?> token = _token; $('#login-form').unbind('submit'); $('#login-form').submit(); <?php endif; ?> } }); isRecaptchaLoaded = true; } scriptTag.parentNode.insertBefore(element, scriptTag); }); </script>