Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 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:

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.

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by magopian

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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 Changed 3 years ago by magopian

  • Cc mathieu.agopian@… added

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.