greggilbert / recaptcha

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

Returns Null #132

Closed jonjie0317 closed 6 years ago

jonjie0317 commented 7 years ago

It returns null when I used dd() in it. My code:

dd($request->input('g-recaptcha-response'));

jonjie0317 commented 7 years ago

it also returns null, because we're just returning all inputs. any idea? need help, Thanks!

jonjie0317 commented 7 years ago

form

<form action="{{ route('auth.form') }}" method="post">
{!! Recaptcha::render() !!}
<input type="submit" value="Submit">
</form>

method

public function postForm(Request $request){
     dd($request->input('g-recaptcha-response'));

     // Some private code...
} 

As simple as that, just for testing, but doesnt work.

m1guelpf commented 7 years ago

@jonjie0317 Maybe you should first validate that that field isn't empty...

greggilbert commented 7 years ago

@jonjie0317 Add dd($request->all()); at the top of postForm (you can also do dd(\Request::all())). Also, are you type sniffing the Request properly? Make sure that the $request object you're looking at is of type Illuminate\Http\Request.

jonjie0317 commented 7 years ago

Yes, I typed it properly Illuminate\Http\Request. I tried dd($request->all());, it returns:

array:11 [▼ "username" => "" "password" => "" "_token" => "75rpLAPo6gXdsP9FLUWA6ma3pvcT4db6agE1yxaRw" ]

..No g-recaptcha-response returns.

ivzinoviev commented 7 years ago

Same issue. If form sended from Firefox always "g-recaptcha-response" => null In Chrome everything working fine. App log clear, no errors in Apache too. Tried set config 'curl_verify' => false, or 'driver' => 'native', But response still null

jonjie0317 commented 7 years ago

@ivzinoviev Have you try to change the place of your {!! Recaptcha::render() !!} in the form? You may try at the beginning of the form. e.g.

<form action="" method="post">
{!! Recaptcha::render() !!}

<!-- Other inputs here... -->
<input type="submit" value="Register">
</form>
ivzinoviev commented 7 years ago

@jonjie0317 Yes, it takes no effect. Only found solution is using https instead http.

UPD: in my case it works only if form accessed via https but act via http. Strange.

jonjie0317 commented 7 years ago

@ivzinoviev Oh, that's great! 👍 thank you for sharing your solution, so this will help others.

vishal-sancheti commented 7 years ago

I am on HTTPS Still face the issue.

Any help?

i350 commented 6 years ago

I replaced the {!! Recaptcha::render() !!} with standard field code

and it works well

ghost commented 6 years ago

If a client-side call to grecaptcha.getResponse() returns a correct response, then this workaround should help solve the problem: Getting Null in g-recaptcha-response Google's reCaptcha