greggilbert / recaptcha

[ABANDONED] reCAPTCHA Validator for Laravel 5
MIT License
714 stars 197 forks source link

reCaptcha failing after succeeds "The given data failed to pass validation" #125

Closed andresrex closed 7 years ago

andresrex commented 7 years ago

So, I have placed the reCaptcha in my login form. I click on "im not a robot" and click on the right images and it says it succeeded, but when I submit the form it returns me the message of "The Captcha field is not correct." and it also thrown and exception saying:

'Illuminate\Foundation\Validation\ValidationException' with message 'The given data failed to pass validation.' I am using "greggilbert/recaptcha" in my Laravel 5.2 project. I have set my keys and everything is working great in production and in other localhost's but not in mine.

My team and I work in the same git repository and it works for everyone but not for me. I have re-installed the plugin, also the whole composer (by deleting vendor and then composer install).

I have cleared the configuration with php artisan config:clear and I've done the composer dump-autoload and have re-publish the ServiceProvider with php artisan vendor:publish --provider="Greggilbert\Recaptcha\RecaptchaServiceProvider"

Does somebody have any idea on how to fix this? Please!

saeedvz commented 7 years ago

i have same problem for some users

ghost commented 7 years ago

Any Results???

greggilbert commented 7 years ago

I'm honestly not sure what to tell you guys. I just did a fresh clone of Laravel 5.3, wired it up with the minimum stuff required, and tested this package - and it works fine.

// the form
<form method="post">
  {{ csrf_field() }}
  {!! Recaptcha::render() !!}
  <input type="submit">
</form>
// the route
Route::post('/', function(\Illuminate\Http\Request $request) {
  $validator = Validator::make($request->all(), [
      'g-recaptcha-response' => 'required|recaptcha',
  ]);

  if ($validator->fails()) {
    echo "You failed.";
  } else {
    echo "YOU PASSED!";
  }
});

If it works for everyone else on your team but not you, then I'd say check your local configuration. Make sure you don't have spaces anywhere in the keys, etc.

pjebs commented 7 years ago

I have same problem. Works perfectly in production. On my local machine using Laravel Valet, it fails 95% of the time so it's quite annoying having to keep submitting a form to test it out.

incon commented 7 years ago

I was also having this issue in my local development environment using Valet. I tracked it down to the curl_timeout After incressing my timeout value I no longer have this issue.

File: config/recaptcha.php

'options'     => [

    'curl_timeout' => 5,

],
pjebs commented 7 years ago

@incon Do you find that all network requests and (external) database queries are very very slow under Valet?

incon commented 7 years ago

@pjebs yes Valet can be slow and at random it can become very slow.

jonjie0317 commented 7 years ago

What if your're not using curl?

pjebs commented 7 years ago

The package uses curl even if you dont

jonjie0317 commented 7 years ago

Ow, sorry. Thats great! I'll try it now Thanks

jonjie0317 commented 7 years ago

BUt why is it returning a null value? I used: dd($request->input('g-recaptcha-response'));

greggilbert commented 7 years ago

@jonjie0317, please don't post across all different issues; it doesn't help things. Open a single ticket if you need help. Anyway, if you do dd(\Request::all()), is there a value for g-recaptcha-response? If not, you're not rendering the form properly.

@pjebs you don't have to use curl; that's what the driver is there for.

jonjie0317 commented 7 years ago

@greggilbert Sorry for that. Thanks a lot for your support 👍

m-elewa commented 6 years ago

here is how to fix it

File: config/recaptcha.php

'driver'      => 'native',