aryehraber / statamic-captcha

Statamic Addon that protects your Statamic forms using a Captcha service.
MIT License
11 stars 8 forks source link

Unfilled captcha doesn't fail form validation #16

Closed roobottom closed 3 years ago

roobottom commented 3 years ago

Hi,

Thanks very much for this add-on. However, I cannot get it to work for love nor money.

I have the capture setup in my form show template as so:

{{ if show_captcha }}
        <div class="form-group{{ if error:captcha }} form-group--error{{ /if }}">
        {{ if error:captcha }}<span class="form-error">{{ error:captcha }}</span>{{ /if }}
        {{ captcha }}
        </div>
      {{ /if }}

Which works! The capture is shown (I've tested both Recaptcha and Hcaptcha)

and my config looks like:

return [
    'service' => 'Hcaptcha', // options: Recaptcha / Hcaptcha
    'sitekey' => env('CAPTCHA_SITEKEY', '[my key is here]'),
    'secret' => env('CAPTCHA_SECRET', '[my secret is here]'),
    'collections' => ['pages'],
    'forms' => ['contact-us'],
    'error_message' => 'Captcha failed.',
    'disclaimer' => '',
    'invisible' => false,
    'hide_badge' => false,
    'enable_api_routes' => false,
];

However, even without filling the captcha, the form is submitted without error.

aryehraber commented 3 years ago

Hi @roobottom, hard to tell what could be going wrong from my end (above details look fine).

To start debugging I would double check these things first:

If all still fails after this, I would jump into the vendor folder and make sure the addon is actually getting called correctly. Drop a dd($submission) on line 23 of this file and resubmit your form (not recommended in production): https://github.com/aryehraber/statamic-captcha/blob/master/src/Listeners/ValidateFormSubmission.php#L23

Good luck!

roobottom commented 3 years ago

I'd used a - and not a _ in the handle.

Thank you so much for your support!