Open seddighi78 opened 5 years ago
The server-side code for verifying the CAPTCHA (as well as the frontend api.js
JS URL) seems to be the same on v2 and v3, so it's just the front-end implementation which would need to be modified. We've decided to stick with v2 for now, but v3 didn't look too difficult to add:
https://developers.google.com/recaptcha/docs/v3#integration
This PHP code from this package's README shows how to manually implement v2 frontend code:
<div id="recaptcha-container"></div>
<script type="text/javascript">
$(document).ready(function() {
$.getScript("<?php echo \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::RECAPTCHA_API_JS_SERVER ?>", function() {
Recaptcha.create("<?php echo $form['recaptcha']->get('public_key') ?>", "recaptcha-container", {
theme: "clean",
});
});
};
</script>
I'm guessing v3 would be something like this:
<script src="<?php echo \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::RECAPTCHA_API_JS_SERVER ?>?render=<?php echo $form['recaptcha']->get('public_key') ?>"></script>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('<?php echo $form['recaptcha']->get('public_key') ?>', {action: 'homepage'}).then(function(token) {
...
});
});
</script>
NOTE: The above code is entirely untested but might be enough to get you started :slightly_smiling_face:
maybe adding a additional configuration with version could be added:
ewz_recaptcha:
version: 'v3' # defaults to v2
so the backward compatibility is given?
So... is it possible to simply do:
ewz_recaptcha:
version: 'v3' # defaults to v2
any updates regarding this?
I'm also interested in this feature.
I made simple bundle for reCAPTHCA v3 if someone want to use https://github.com/prugala/PRRecaptchaBundle
@spavanes @man-andy
I made simple bundle for reCAPTHCA v3 if someone want to use https://github.com/prugala/PRRecaptchaBundle
@spavanes @man-andy
I'm intersting but i need to use it on an old symfony version (2.7). Is it compatible ?
I've tried suggestion from @alexander-schranz
ewz_recaptcha:
version: 'v3' # defaults to v2
But this option does not exists in current version 1.5:
Unrecognized option "version" under "ewz_recaptcha".
Any ideas?
@itinance it was idea only. As I wrote above I made simple bundle for Recaptcha V3: https://github.com/prugala/PRRecaptchaBundle
This seems to be implemented in #256 Thx to @manuxi
Is possible to use the ReCaptcha version 3 and if yes how to use it?