Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#15911 closed Bug (worksforme)

In django.contrib.auth.forms.AuthenticationForm there is no separate check for empty form input

Reported by: lgp171188@… Owned by: nobody
Component: contrib.auth Version: 1.3
Severity: Normal Keywords:
Cc: mathieu.agopian@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In django.contrib.auth.forms.AuthenticationForm there is no check check for empty form input data and treat it as a separate validation error. Instead it returns the generic Your username and password didn't match. Please try again. which is more appropriate for invalid credentials.

Change History (2)

comment:1 by Mathieu Agopian, 14 years ago

Resolution: worksforme
Status: newclosed

I'm going to close this ticket as "worksforme", as with the information you provided, i couldn't reproduce the bug.

Please, if you believe this is indeed a bug, feel free to reopen this ticket, and provide extensive details on how to reproduce it, thanks !

FYI, here's the code I used to try to reproduce the bug:

# views.py
class MyFormView(FormView):
    template_name = 'testapp/form.html'
    form_class = AuthenticationForm
    success_url = "/"
form_view = MyFormView.as_view()


# urls.py
from testapp.views import form_view

urlpatterns = patterns('',
    url(r'^form/$', form_view, name='form'),
)


# templates/testapp/form.html
<form method="post" action="">{% csrf_token %}
    {% include "form_include.html" %}
    <input type="submit" value="submit" />
</form>


# form_include.html
{% if form.errors %}
<p class="error">Please correct the following errors:</p>
{% endif %}

{% for field in form %}
    <div class="form-row{% if field.field.required %} required{% endif %}{% if field.errors %} error{% endif %}">
        {{ field.errors }}
        {{ field.label_tag }} {{ field }}
        {% if field.help_text %}<p class="help">{{ field.help_text }}</p>{% endif %}
    </div>
{% endfor %}

When i go to /form/, i do indeed see a username and a password input fields, and if i submit straight away, without submitting any data, there's an error for each field stating "This field is required."

comment:2 by Mathieu Agopian, 14 years ago

Cc: mathieu.agopian@… added
Note: See TracTickets for help on using tickets.
Back to Top