excelwebzone / EWZRecaptchaBundle

This bundle provides easy reCAPTCHA form field for Symfony.
MIT License
395 stars 160 forks source link

Enable caching recaptcha verify response in array cache #245

Closed pulzarraider closed 4 years ago

pulzarraider commented 4 years ago

There are few situations when you have to call the IsTrueValidator twice in one request. This is not possible now, because Google recaptcha accepts the value only once. So first validation will pass, second will fail.

This PR enables the caching of the recaptcha response, so the IsTrueValidator (and their dependencies) will use the response from the first verify call.

The IsTrueValidator is also simplified with the dependency injection. Recaptcha serivce is not creating during the validation process, but is injected to the constraint as dependency.

pulzarraider commented 4 years ago

Thank you @excelwebzone.

ossinkine commented 4 years ago

@excelwebzone @pulzarraider This MR breaks BC, because public constructor of IsTrueValidator was changed.

Moreover, before this MR, Recaptcha object is created if the enabled flag is true, right now it's created whenever the validator is created, and if the captcha not configured (f.e. private key is not specified) and disabled an error appears. And this refactoring is not required for caching requests.

So please rollback this MR.