Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typhoon] Captcha check always failing on Typhoon modular page #438

Open
snakefox opened this issue May 14, 2024 · 11 comments
Open

[typhoon] Captcha check always failing on Typhoon modular page #438

snakefox opened this issue May 14, 2024 · 11 comments
Assignees
Labels
cannot reproduce Can't reproduced the issue with the information provided typhoon Typhoon theme

Comments

@snakefox
Copy link

Hi,

I added the contact form to my modular Typhoon page and also enabled basic captcha as described here

The check is always failing even if the answer is correct and no mail is sent.
There is no answer on that thread. Can someone please help ?

Thank you

@snakefox snakefox added the typhoon Typhoon theme label May 14, 2024
@rhukster
Copy link
Member

Make sure you have never_cache_twig: true in your modular page either the form.

@snakefox
Copy link
Author

snakefox commented May 14, 2024

Hi,

I tried it but still the same. Here is my config:

modular page:

title: 'Secure Systems Design Lab'
content:
    items: self@.modular
onpage_menu: true
never_cache_twig: true
cache_enable: false

contact page:

body_classes: modular
cache_enable: false
never_cache_twig: true
form:
    name: contact
    action: '#contact'
    inline_errors: true
    fields:
        email:
            label: Email
            display_label: false
            placeholder: Mail
            type: email
            validate:
                required: true
        message:
            label: Message
            display_label: false
            placeholder: Nachricht
            type: textarea
            rows: 5
            minlength: 10
            maxlength: 255
            validate:
                required: true
        note:
            label: Hinweis
            display_label: false
            type: display
            size: large
            markdown: true
            classes: 'text-gray-600 dark:text-gray-400'
            content: '<center>Wir verwenden Ihre Angaben für die Bearbeitung von Anfragen. Unter <b><a href="https://cybermynd.io/de/datenschutz" target="_blank">Datenschutz</a></b> finden Sie weitere Informationen.</center>'
        basic-captcha:
            type: basic-captcha
            placeholder: Antwort
            display_label: false
    buttons:
        submit:
            type: submit
            classes: 'no-default-style text-white bg-primary hover:bg-red-800'
            value: Abschicken
    process:
        basic-captcha:
            message: 'Bitte nochmal versuchen..'
        email:
            from: '{{ config.plugins.email.from }}'
            to: '{{ config.plugins.email.to }}'
            subject: '[Kundenanfrage] cybermynd GmbH'
            body: '{% include ''forms/data.html.twig'' %}'
        message: '<b>Vielen Dank!</b> Wir melden uns zeitnah bei Ihnen.'
        reset: true
menu: Kontakt

I disabled all caching mechanisms on all levels as well.

@rhukster
Copy link
Member

I can't really debug from 'inline' code.. you need to keep your newlines.. please insert code between triple backticks: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks

@snakefox
Copy link
Author

Hi @rhukster,

sorry, I did not know how to do that but now it is fixed :- )

BR

@snakefox
Copy link
Author

snakefox commented Jun 2, 2024

Hi @rhukster
Do you have any updates ? It is very important to have a basic captcha in place to prevent from being overflooded by mails.

Thank you

@rhukster
Copy link
Member

rhukster commented Jun 2, 2024

I don't see any issues with your form, if you remove the captcha: bit from your process, does the form submit correctly? Do you have a live site i can take a look at?

@snakefox
Copy link
Author

snakefox commented Jun 2, 2024

Hi @rhukster,

you can find my live site here. Please scroll down to find the contact form.

Shall I change basic-captcha: to basic in process section ?

@rhukster
Copy link
Member

rhukster commented Jun 4, 2024

process should definitely be basic-captcha:

I just tested a modular page (with cache enabled, even XHR enabled):

---
title: Modular Form B

form:
  name: Form B
  xhr_submit: true
  inline_errors: true
  fields:
    something:
      type: text
      label: Something Else
      validate:
        required: true
    basic-captcha:
      type: basic-captcha
      placeholder: copy the 6 characters
      label: Are you human?   
        
  buttons:
    submit:
      type: submit
      value: Submit
      
  process:
    basic-captcha:
      message: Humanity verification failed, please try again...
    message: "Thank you from your submission <b>{{ form.value('person.name') }}</b>!"
    reset: true
---

## XHR Modular Form

And it works 100% of the time as expected:

CleanShot 2024-06-04 at 13 10 58

@snakefox
Copy link
Author

snakefox commented Jun 5, 2024

Hi @rhukster

still does not work for me. I switched to a honeypot instead to have some spam protection in place:

{% extends "forms/field.html.twig" %}

{% block field %}
{% set input_value = value is iterable ? value|join(',') : value|string %}
<input aria-hidden="true"
       type="text"
       {% if config.plugins.form.inline_css == true %}
       style="display:none;position:absolute!important;height:1px;width:1px;overflow:hidden;clip-path:inset(50%);"
       {% endif %}
       class="form-honeybear"
       name="{{ (scope ~ field.name)|fieldName }}"
       value="{{ input_value|e }}"
       tabindex="-1"
       autocomplete="off" />
{% endblock %}

@rhukster
Copy link
Member

rhukster commented Jun 5, 2024

If you want, you can zip up your site and PM me how i can download it (on discord), then I can try to debug the issue you are having, because I currently can't replicate it.

@rhukster rhukster added the cannot reproduce Can't reproduced the issue with the information provided label Jun 5, 2024
@snakefox
Copy link
Author

snakefox commented Jun 5, 2024

It is not required, thank you. I will come back if that kind of spam protection is not enough :- ) I just modified your honeypot.html.twig based on some articles I have found.

  • replaced visibility by display
  • replaced clip by clip-path
  • added tabindex="-1"
  • added autocomplete="off"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cannot reproduce Can't reproduced the issue with the information provided typhoon Typhoon theme
Projects
None yet
Development

No branches or pull requests

2 participants