Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Forum Module /

Discuss the Forum Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SilverStripe forums + Recaptcha module


Go to End


2 Posts   3915 Views

Avatar
forumq42

Community Member, 18 Posts

15 May 2013 at 7:12am

http://www.silverstripe.org/recaptcha-module/

I had SilverStripe 2.4.x + the Forum module + Recaptcha (+Spam Protection module) working on a fresh install of SilverStripe. However, repeating the same steps on the production server I seem to be getting the response:

"Your answer didn't match the captcha words, please try again"

after submitting the Forum user registration form, even when the Recaptcha is obviously correct.

I'm wondering if there's some domain/keys issue. I've tried using public/private global keys for both the domain of the URL (http://foo.bar.org) and the hostname of the actual web servers (let's say: server1.gronk.org).

The steps I have done are basically:

- installed Forum module
- installed Recaptcha into /html/recaptcha
- registered w/google.com/recaptcha and generated a public/private keypair for the domain I am using
- installed Spam Protection module into /html/spamprotector
- /dev/build on the site
- ?flush=1 on the site

- in /mysite/_config.php added 3 lines:
RecaptchaField::$public_api_key = '<public key copied from google.com/recaptcha>';
RecaptchaField::$private_api_key = '<private key copied from google.com/recaptcha>'';
SpamProtectorManager::set_spam_protector('RecaptchaProtector');

- in /forums/code, edited 2 files: ForumMemberProfile.php, ForumRole.php

ForumMemberProfile.php, added this line under line 165 the check "if(class_exists('SpamProtectionManager')":
$protector = SpamProtectorManager::update_form($form, 'MyCaptcha'); // to make the recaptcha work with your form

ForumRole.php, added a recaptca field under line 171 to the $personalDetailsField form code:
new RecaptchaField('MyCaptcha')

A Recpatcha image box appears but 100% of the time after the form is submitted the response is:
"Your answer didn't match the captcha words, please try again"

and the user is not registered but rather brought back to the form back to try again. Is there something obvious I am forgetting?

Suggestions?

Avatar
forumq42

Community Member, 18 Posts

17 May 2013 at 6:50am

Resolved.

The issue was neither the keys nor any sort of firewall issue.

The issue was there were 2 captcha fields being created, and they must have been one on top of the other on the page because it appeared only 1 was on the page when the registration form appeared. However after submitting and looking at the network traffic it was obvious 2 challenges were being sent to Google/recaptcha. The first returned as correct, the second always returning incorrect. Additionally, looking at the page source there were 2 different regions that called recaptcha Javascript code which looked suspicious.

I had added the line:
$protector = SpamProtectorManager::update_form($form, 'MyCaptcha');

to ForumMemberProfile.php and also added a Recaptcha field to the forum. From what I gather, the Spam Protection module must generate that on it's own when it's configured to use Recaptcha so in essence I had added a 2nd field. I removed the added 2 lines and things were working. Checking the network traffic there was then only a single challenge to Google/recaptcha.