verto-health / ngx-turnstile

Cloudflare Turnstile for Angular
https://ngx-turnstile.pages.dev/
MIT License
62 stars 13 forks source link

Local development improvement request #33

Closed zygimantas closed 3 months ago

zygimantas commented 3 months ago

Would it be possible to have enabled (boolean) property?

Use case:

When developing on localhost, it would be good option to set [enabled]="environment.production" disable functionality of widget. Otherwise, it must be used like this:

@if (environment.production) {
  <ngx-turnstile [(ngModel)]="token" />
}

which makes form.value.token undefined in template driven form.

Suggested solution:

<ngx-turnstile [(ngModel)]="token" [enabled]="environment.production" />
choyiny commented 3 months ago

So far, we have not encountered a situation where it should be disabled in development mode. Since our backend always have the validation code, we opted in to put in test keys on both frontend and backend so the validation always succeeds: https://developers.cloudflare.com/turnstile/troubleshooting/testing/

Does this work for your use case? If not, can you tell me more about why you need to disable the widget in development mode?

zygimantas commented 3 months ago

Yes, that would work in my case. Thank you.