greggilbert / recaptcha

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

Validation always NOT CORRECT #130

Closed jonjie0317 closed 7 years ago

jonjie0317 commented 7 years ago

I followed the installation and set up successfully, but when I tried it correctly (Check the "Im not a robot"), it always says, The g-recaptcha-response field is required. What happened to that?

Need Help guys. btw Im using Laravel 5.1

Heres my code

Form:

<div class="form-group{{ $errors->has('g-recaptcha-response') ? ' has-error' : '' }}">
    {!! Recaptcha::render() !!}
    @if($errors->has('g-recaptcha-response'))
        <span class="help-block">
            {{ $errors->first('g-recaptcha-response') }}
        </span>
    @endif
</div>

===================================================================

Validation

$this->validate($request, [
    'username' => 'required',
    'password' => 'required|min:6',
    'password_again' => 'required|same:password',
    'email' => 'required|email|max:255',
    'g-recaptcha-response' => 'required|recaptcha'
]);
alofeoluwafemi commented 7 years ago

Am stuck here also. I have the same issue! Anyone can help?

jonjie0317 commented 7 years ago

Yah, I have also checked all the required info like the secret and the public key but still doesn't work, @slim12kg tell me your solution once you solved it. Many thanks!

alofeoluwafemi commented 7 years ago

I discovered that if am connected to my office network, i don't have the issue anymore but the error occurs when am connected to my mobile hotspot. I don't know why that occurs

dena-a commented 7 years ago

I have this issue on firefox only, not on google chrome. Any idea?

alofeoluwafemi commented 7 years ago

Do you have proxy setup on firefox. That might be a problem

dena-a commented 7 years ago

@slim12kg No I don't. I should to use another package.

greggilbert commented 7 years ago

Okay, so I just pushed a change that does two things:

  1. Makes curl verify by default, but allows it to be disabled if you need that
  2. Logs any curl errors

Note that this comes with a config change, so in the recaptcha.php config, add:

    'options'     => [
        'curl_verify' => true,
    ],

as part of the other options in there.

Let me know if that doesn't work.

jonjie0317 commented 7 years ago

Still doesn't work sir :( same error/bug.

Here's my recaptcha.php:


return [

    'public_key'     => env('RECAPTCHA_PUBLIC_KEY', 'my_site_key'),
    'private_key'    => env('RECAPTCHA_PRIVATE_KEY', 'my_secret_key'),

    'template'    => '',

    'driver'      => 'curl',

    'options'     => [

        'curl_timeout' => 1,
        'curl_verify' => true,

    ],

    'version'     => 2,

. Or should I have to change my driver ? What should I do?

Here's my validation:

$this->validate($request, [
     'username' => 'required',
         'password' => 'required',
         'g-recaptcha-response' => 'required|recaptcha',
]);

My view: register.blade.php

{!! Recaptcha::render() !!}

greggilbert commented 7 years ago

Can you check the logs and see if there was a curl error?

jonjie0317 commented 7 years ago

@greggilbert Sorry for this stupid question, but how can I check those logs? to see the error? I also change curl_timeout to 5/10, as per other tickets, but still not working.

greggilbert commented 7 years ago

It's a Laravel setting. I believe the default is storage/logs/laravel-*.log, but it depends on your config.

jonjie0317 commented 7 years ago

Theres no curl error sir :(

greggilbert commented 7 years ago

Did you turn on debug? Try to raise up the error reporting as much as possible. Look at all the logs, not just the Laravel ones. httpd or nginx, php-fpm, etc. - i need _something_to go on.

jonjie0317 commented 7 years ago

@greggilbert It worked sir, hahaha! yes! but not totally, 👍 I mean, If I put the {!! Recaptcha::render() !!} at the top of all input in the view, its working, but if I put it before the button or at the bottom of all inputs, the form submittion cant detect the recaptcha. (If I put it before all inputs, its not good)

m-elewa commented 6 years ago

here is how to fix it

File: config/recaptcha.php

'driver'      => 'native',
bertalanimre commented 6 years ago

Nope, not for me. :( Tried both solutions, none foo them worked. Any more ideas?

digitalformula commented 5 years ago

here is how to fix it

File: config/recaptcha.php

'driver'      => 'native',

This fixed the issue for me just now. I'm on Laravel 5.6 in prod.