greggilbert / recaptcha

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

Validation fails. Error code: timeout-or-duplicate #140

Open cyberdevteam opened 7 years ago

cyberdevteam commented 7 years ago

Everything was working fine until last week when every validation fails with the error code "timeout-or-duplicate". After adding some debug lines this is what I get:

[2017-07-06 14:58:48] local.DEBUG: [Recaptcha] Request: https://www.google.com/recaptcha/api/siteverify?secret=....
[2017-07-06 14:58:48] local.DEBUG: [Recaptcha] Response: {
  "success": true,
  "challenge_ts": "2017-07-06T18:58:05Z",
  "hostname": "vagrant.local"
}
[2017-07-06 14:58:49] local.DEBUG: [Recaptcha] Request: https://www.google.com/recaptcha/api/siteverify?secret=...
[2017-07-06 14:58:49] local.DEBUG: [Recaptcha] Response: {
  "success": false,
  "challenge_ts": "2017-07-06T18:58:05Z",
  "hostname": "vagrant.local",
  "error-codes": [
    "timeout-or-duplicate"
  ]
}

It seems that in every validation two calls are made, so Google response is true for the first and false for the second since is considered duplicate.

I'm using a request validation object and my rules are set like this:

/**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'motive' => 'required',
            'name' => 'required|min:3|max:250',
            'last_name' => 'required|min:3|max:250',
            'address' => 'required|min:3|max:250',
            'address_number' => 'required|integer|min:0',
            'address_info' => 'max:250',
            'email' => 'required|email|max:250',
            'event_address' => 'required|min:3|max:250',
            'event_address_number' => 'required|integer|min:0',
            'event_address_info' => 'max:250',
            'message' => 'required|min:3|max:1000',
            'g-recaptcha-response'  => 'required|recaptcha',
        ];
        return $rules;
    }

Any ideas how to prevent duplicate calls to google recaptcha API?

singhservesh commented 7 years ago

Please check this : https://stackoverflow.com/questions/43678256/google-recaptcha-response-success-false-no-error-codes/45659347#45659347

TWilson023 commented 6 years ago

Having this same issue (validator running twice), but with my own Recaptcha validation code. Could this be an obscure Laravel issue?

singhservesh commented 6 years ago

@TWilson023 Can you explain issue in detail. It seems you are validating same user captcha response twice. What api are you using for validating captcha response ? Can you paste you code snippet which does validation ?

ArtiDjeims commented 5 years ago

This might require resetting your captcha, to prevent duplicates. Try calling the grecaptcha.reset();

reference: https://developers.google.com/recaptcha/docs/display#render_param