clarknelson / craft-recaptcha-3

A Craft CMS 3 plugin to verify the user's humanity via Google's reCAPTCHA v3.
MIT License
9 stars 2 forks source link

Extend for plugins/modules #14

Open jakepm opened 4 years ago

jakepm commented 4 years ago

I understand that this plugin is designed to be an entirely client-side solution, but would it be possible/easy to extend this plugin so that it can be used in a Craft plugin or module?

In a controller action it would be really handy if we could do a one-liner call to the plugin to validate a token, which could be include in the front-end form ( eg. {% include ['_recaptcha/token'] %} ).

clarknelson commented 4 years ago

Google's reCaptcha 3 is actually a two part solution, there is code being run on the front-end and the back-end. I don't think it's possible to validate entirely on the backend to use this in PHP code. So you are looking for a controller action to hit with your plugin? I believe reCaptcha uses browser data such as cookies to determine if the user is a bot or not. Hopefully this helps, would like to know more about your use case.

jakepm commented 4 years ago

I was just hoping to handle the back-end component in my own module rather than your plugin, so that the reCAPTCHA check can happen on form post rather than as an Ajax call from the front end.

Not a problem if you can't support this though, the plugin works great as a standalone solution that does the back-end post over Ajax.

clarknelson commented 4 years ago

Thanks for the comment, I want to go back and add support for .env variables and maybe an ability to hide the front-end. Just want to make sure I understand what people are asking for so I can try to add that also.