Cakephp 2.0 ReCaptcha插件总是错误的

时间:2012-05-27 22:07:49

标签: cakephp cakephp-2.0 recaptcha

我从this guy获取了一个reCaptcha插件 (插件的github link

我在视图中输入了以下代码表单:

[form creation]
[table]
[inputs]
[/table]
echo $this->Recaptcha->show(array('theme' => 'white'));
echo $this->Recaptcha->error();  

[/form] 

我已按照建议的步骤操作,并且reCaptcha窗口正确显示,但无论我在验证码中输入什么,它都永远不会得到验证,我总是收到beforeValidate的'message'字段(我已将其设置为“你输了一个错误的信息”等等。

我甚至不确定如何调试它以查看它失败的那一点。即使我只是将checkRecaptcha函数中的所有代码替换为“return true”来尝试使用键跳过验证,只是看看规则本身是否正确,它仍然保持不变,而我通常不会得到任何我读过的具体incorrect-captcha-sol条消息。

我是否正确地假设我在控制器功能中需要的唯一代码(假设我已经在控制器中包含了组件和帮助器)是Configure::load('Recaptcha.key');并且没有进一步的手动验证检查?

(很遗憾,由于权利,我无法将您的整个项目链接到您)

1 个答案:

答案 0 :(得分:2)

我有类似的问题。尝试删除组件中的2响应和挑战字段行,并用以下内容覆盖它们:

$controller->$modelClass->set('recaptcha_response_field',  
$controller->request->data['recaptcha_response_field']);  
$controller->$modelClass->set('recaptcha_challenge_field',  
$controller->request->data['recaptcha_challenge_field']);