Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cyberdevteam opened this issue Jul 6, 2017 · 4 comments
Open

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

cyberdevteam opened this issue Jul 6, 2017 · 4 comments

Comments

@cyberdevteam
Copy link

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?

@TWilson023
Copy link

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

@singhservesh
Copy link

@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 ?

salexch added a commit to salexch/recaptcha that referenced this issue Jul 1, 2018
it could be nice to cache the first response,
so in the code if the same validation is called few times it will return the first validation result
salexch added a commit to salexch/recaptcha that referenced this issue Jul 1, 2018
salexch pushed a commit to salexch/recaptcha that referenced this issue Jul 1, 2018
@ArtiDjeims
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants