billmn / craft-turnstile

Cloudflare Turnstile integration for Craft CMS.
MIT License
3 stars 1 forks source link

Turnstile always returning failed #1

Closed andrewhawkes closed 1 year ago

andrewhawkes commented 1 year ago

I've followed the docs and added a check for Craft's contact form plugin to block the sending of submissions if the Turnstile validator fails.

The captcha is loading as expected on the front end. I've tried locally and on a live domain and the following always gives a failed captcha challenge.

Turnstile::getInstance()->validator->verify(); returns false Turnstile::getInstance()->validator->passes(); returns false Turnstile::getInstance()->validator->fails(); returns true

I'm passing real data and the captcha appears to pass on the front end.

billmn commented 1 year ago

Hey @andrewhawkes, did you check the log file for any errors?

andrewhawkes commented 1 year ago

@billmn ahh sorry - I didn't look (weekend dev brain!)

Looks like there are some errors

2023-08-06 11:17:38 [web.ERROR] [billmn\turnstile\services\Validator::verify] {"success":false,"error-codes":["invalid-input-secret"],"messages":[]} {"memory":24941064} 
billmn commented 1 year ago

Have you entered both site and secret keys?

Seems the secret was invalid: https://developers.cloudflare.com/turnstile/get-started/server-side-validation/#error-codes

andrewhawkes commented 1 year ago

@billmn turns out I'd passed the site key twice in the plugin options from my environment variables 🙄 It's working as expected now. Thanks for your help!