Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disfunctional package #98

Open
TheNewSound opened this issue Jan 14, 2025 · 0 comments
Open

Disfunctional package #98

TheNewSound opened this issue Jan 14, 2025 · 0 comments

Comments

@TheNewSound
Copy link

TheNewSound commented Jan 14, 2025

This package does not correctly implement the retrieval of a response code in the client side.
This has cost me a lot of missed form submissions!!!

You need to call grecaptcha.execute() upon form submission! not upon page load!
After two minutes the token will timeout.

Use this code instead of renderField() :

<input type="hidden" name="g-recaptcha-response" />
<script>
    (function() {
        document.getElementById('contact_form').addEventListener("submit", function(event) {
            event.preventDefault()
            grecaptcha.ready(() => {
                grecaptcha.execute('{{ config('googlerecaptchav3.site_key') }}', {action: 'contact_us'}).then((token) => {
                    event.target.querySelector('input[name="g-recaptcha-response"]').value=token
                    event.target.submit()
                })
            }, false)
        })
    })();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant