Skip to content

mock_enabled and enabled conflict #231

@ChaelCodes

Description

@ChaelCodes

If mock_enabled and enabled are both true, then the real cloudflare widget is rendered instead of the mock. By default, enabled is true, so the mock never renders.

In order to see the mock, you need to set mock_enabled to true, and enabled to false, so you end up setting these to the inverse of each other.

This contradicts the behavior described in the README, which says enabled completely disables the widget.

To totally disable Turnstile, you can set c.enabled = false and all other config values are ignored.

I believe the root of the issue is here:

def cloudflare_turnstile_script_tag(async: true, defer: true, explicit: false)
if RailsCloudflareTurnstile.enabled?
content_tag(:script, src: js_src(explicit:), async: async, defer: defer, data: {turbo_track: "reload", turbo_temporary: true}) do
""
end
elsif RailsCloudflareTurnstile.mock_enabled?
content_tag(:script, src: mock_js, async: async, defer: defer, data: {turbo_track: "reload", turbo_temporary: true}) do
""
end
end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions