Permalink
Browse files

Merge pull request #3 from flack/patch-1

Add support for passing challenge/response manually
  • Loading branch information...
2 parents f4a0736 + ce1bf9f commit 6fc690fe0fb5f4cb713567f9fb0641d799f742ae @AlekseyKorzun committed Mar 26, 2013
Showing with 8 additions and 8 deletions.
  1. +8 −8 Package/Captcha/Captcha.php
@@ -208,22 +208,22 @@ public function html()
/**
* Checks and validates user's response
*
+ * @param string $captcha_challenge Optional challenge string. If empty, value from $_POST will be used
+ * @param string $captcha_response Optional response string. If empty, value from $_POST will be used
* @throws Exception
* @return Response
*/
- public function check()
+ public function check($captcha_challenge = false, $captcha_response = false)
{
if (!$this->getPrivateKey()) {
throw new Exception('You must set private key provided by reCaptcha');
}
-
- $captcha_challenge = false;
- $captcha_response = false;
-
// Skip processing of empty data
- if (isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field'])) {
- $captcha_challenge = $_POST['recaptcha_challenge_field'];
- $captcha_response = $_POST['recaptcha_response_field'];
+ if (!$captcha_challenge && !$captcha_response) {
+ if (isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field'])) {
+ $captcha_challenge = $_POST['recaptcha_challenge_field'];
+ $captcha_response = $_POST['recaptcha_response_field'];
+ }
}
// Instance of response object

0 comments on commit 6fc690f

Please sign in to comment.