UndefinedOffset / silverstripe-nocaptcha

A spam protector and form field using Google's reCAPTCHA v2 or optionally a foundation v3 implementation
BSD 3-Clause "New" or "Revised" License
31 stars 37 forks source link

Captcha could not be validated. #8

Closed helenclarko closed 9 years ago

helenclarko commented 9 years ago

After submitting form, an error shows under the nocatcha "Captcha could not be validated." Form is then not submitted.

Silverstripe 3.1

UndefinedOffset commented 9 years ago

Have you checked that the site key and secret key are correct? Are you using Ajax to submit the form? Also double check that you have authorized the domain on google's end.

helenclarko commented 9 years ago

Site Key and Secret Key are correct. Silverstripe UserForms is being used, so just standard submit.

UndefinedOffset commented 9 years ago

I wonder is there client side validation happening per chance from user forms? I'm wondering if that maybe a clue, I'll do some testing on the weekend. It could be seeing it as required and validating it.

helenclarko commented 9 years ago

Yea, I assumed that the userform wasnt getting the correct response.

UndefinedOffset commented 9 years ago

Ya if it's doing client side validation it maybe capturing the submit event which is likely preventing googles code from populating the value needed for the server side validation. You could try turning off the client side validation in the user forms settings. It may help. I'll do some testing on the weekend see if I can figure it out, what version of user forms are you using?

UndefinedOffset commented 9 years ago

I just tested with the latest master of userforms and 3.1.12 as well as the latest master of this module. Which is the same as the 0.1.3 tag with the exception of some documentation changes. It seemed to work correctly for me, can you post your composer.lock file?

helenclarko commented 9 years ago

Hi UndefinedOffset,

I have manually copied all files (not using Composer). I have just swapped out Spam Protection, nocaptcha and Userforms. Everytime I submit a form, I recieve an error "Captcha could not be validated".

Is this likely to be the Keys I have entered, or Userforms trying to validate the Nocaptcha field?

UndefinedOffset commented 9 years ago

My guess would be that the domain you are using is not allowed for the keys you have setup. Make sure you have allowed the domain you are working off in googles recaptcha panel for the keys.

UndefinedOffset commented 9 years ago

Also try var dumping the response variable before this line https://github.com/UndefinedOffset/silverstripe-nocaptcha/blob/master/code/NocaptchaField.php#L141 also try dumping out curl_error($ch), may need to check that function name to be sure I'm right ;). Could be an error too

helenclarko commented 9 years ago

I believe the keys are working without any issue, If I swap them out for a different domain, it shows an error, something about the keys are not for this domian".

Think we solved the problem. Our servers dont have SSL, so CURL needed to have verify set to false.

UndefinedOffset commented 9 years ago

Ok cool you can set that on the config for the field (see the read me) for that, that way you won't have to modify the module :) let me know if the problem is solved and I'll close this issue

helenclarko commented 9 years ago

All solved. Thanks!