aryehraber / statamic-captcha

Statamic Addon that protects your Statamic forms using a Captcha service.
MIT License
11 stars 8 forks source link

Add Altcha support #53

Open grantholle opened 5 months ago

grantholle commented 5 months ago

This PR integrates Altcha into the package.

aryehraber commented 5 months ago

Nice one, @grantholle! I hadn't heard of Altcha before, looks cool 👌

Happy to review this PR once you're ready, will leave it for now since it's a "Draft".

grantholle commented 5 months ago

Yeah, I've had to do something a little hacky to get it to work with Vue and my site. It seems to work, but I don't love it. If you look at resources/views/altcha/head.blade.php, I'm basically waiting until the DOM is loaded then injecting it manually.

It's working on the site I'm testing with, but feels a little wrong to do it that way. However, when I do it the right way, Vue renderers it twice. I think to fix it, I'm going to have to refactor my frontend and how I'm using Vue. You can see the issue I made for it, but I discovered it's Vue's fault.

aryehraber commented 5 months ago

Yeah, using Statamic Captcha in an SPA/Ajax setup hasn't been a great experience tbh.

I've had issues in the past having Vue & Alpine.js play nice with reCaptcha & hCaptcha due to similar reasons. It's been a little while now, but I think I had the opposite problem, where NO captcha would load due to Vue/Alpine.js not being ready at the "right" time.

I ended up taking manual control from within my JS code in those cases. For example, I would exclude Captcha's tags and run the necessary captcha init & execution code myself from inside the Vue component. I kind of explained it in an issue a while ago, but probably could use a full explanation in Captcha's docs... https://github.com/aryehraber/statamic-captcha/issues/14#issuecomment-1025766126 -- what you end up with is just using this addon as a backend, and handling the frontend yourself.

Hope that makes sense/helps!