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

hCaptcha disappears when browser window is too small #10

Open
AmmonQ opened this issue Jul 18, 2022 · 5 comments
Open

hCaptcha disappears when browser window is too small #10

AmmonQ opened this issue Jul 18, 2022 · 5 comments

Comments

@AmmonQ
Copy link

AmmonQ commented Jul 18, 2022

The hCaptcha disappears when browser window is too small. This means people using my website on a mobile device will have problems.

@AndrejZbin
Copy link
Owner

I failed to reproduce this issue. Can you please provide example code?

@AmmonQ
Copy link
Author

AmmonQ commented Aug 16, 2022

I noticed this problem with Google's reCAPTCHA as well.

@AmmonQ
Copy link
Author

AmmonQ commented Aug 16, 2022

This is my function in my views.py file.

def sidebar_directory_page(request, template='sidebarlandingpage/sidebar_directory_page.html'):
    if request.method == 'POST':
        form = HcaptchaForm(request.POST)

        if form.is_valid():
            return SidebarDirectoryPage.objects.first().serve(request)
        else:
            return render(request, 'sidebarlandingpage/captcha_page.html', {'captcha_form': form})

    else:
        form = HcaptchaForm(request.POST)
        return render(request, 'sidebarlandingpage/captcha_page.html', {'captcha_form': form})

@AmmonQ
Copy link
Author

AmmonQ commented Aug 16, 2022

And this is my template file captcha_page.html:

{% extends "base.html" %}
{% load static wagtailcore_tags wagtailimages_tags wagtailembeds_tags %}

{% block main %}

    {% image page.get_parent.specific.hero_image fill-900x400 as img %}

    <div class="row">
        <div class="col-sm-2"></div>

        <div class="col-sm-6" style="margin-top: 1em;">
            <p>If the CAPTCHA does not appear, make your browser window wider. If you are on a mobile device,
                try rotating your screen.</p>
            <p>{{ captcha_response }}</p>

            <form action="" method="POST">
                {% csrf_token %}
                {{ captcha_form }}
                <input class="btn btn-primary" type="submit" value="Click here after completing the CAPTCHA">
            </form>
        </div>

        <div class="col-sm-2"></div>
    </div>

{% endblock main %}

@AmmonQ
Copy link
Author

AmmonQ commented Aug 16, 2022

And my form in forms.py as well:

from django.forms import forms
from hcaptcha.fields import hCaptchaField


class HcaptchaForm(forms.Form):
    hcapthca = hCaptchaField(required=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants