Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19368 closed Cleanup/optimization (fixed)

Custom User without username and with USERNAME_FIELD = 'email', but still see username error message at the admin login page

Reported by: Val Neekman Owned by: nobody
Component: contrib.admin Version: 1.5-alpha-1
Severity: Release blocker Keywords: custom user, USERNAME_FIELD, username
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

Have a custom user with no username and have set USERNAME_FIELD = 'email'.
All works great, however, the error messages are still pointing to the username even though the custom user had no username field.

Here is where the error message comes from.
ERROR_MESSAGE = ugettext_lazy("Please enter the correct username and password "

"for a staff account. Note that both fields are case-sensitive.")

Attachments (2)

django_admin.png (31.9 KB ) - added by Val Neekman 12 years ago.
Admin Login with Email still warns about username
19368.patch (1.4 KB ) - added by Aymeric Augustin 12 years ago.

Download all attachments as: .zip

Change History (11)

by Val Neekman, 12 years ago

Attachment: django_admin.png added

Admin Login with Email still warns about username

comment:1 by Aymeric Augustin, 12 years ago

Triage Stage: UnreviewedAccepted

This message is hardcoded in django.contrib.admin.forms.AdminAuthenticationForm.

AdminAuthenticationForm inherits django.contrib.auth.forms.AuthenticationForm. That class is aware of custom user models: it sets an appropriate label on the username field.

AdminAuthenticationForm should reflect this. Replacing "username and password" by "credentials" should suffice.

by Aymeric Augustin, 12 years ago

Attachment: 19368.patch added

comment:2 by Aymeric Augustin, 12 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

Trivial patch attached, I'll just wait for a few days to see in case Russell disagrees.

This should be committed before the string freeze.

comment:3 by Aymeric Augustin, 12 years ago

Severity: NormalRelease blocker

comment:4 by Preston Holmes, 12 years ago

I'd only add that the language should be changed to say "Note that fields *may* be case-sensitive" which is sort of a cop out - but we now can't know the implementation, and it at least gives the user a heads up if they are forgetting that - esp for hidden PW field.

comment:5 by Russell Keith-Magee, 12 years ago

Rather than try to find a generic term, we can substitute the name of the username field as an argument to the error message. The patch isn't that complicated, either; I'll commit shortly.

comment:6 by Russell Keith-Magee <russell@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 27f8129d64292868f6a328f7bf9a1bed67967ff3:

Fixed #19368 -- Ensured that login error messages adapt to changes in the User model.

Thanks to un33k for the report.

comment:7 by Russell Keith-Magee <russell@…>, 12 years ago

In 9534192c107aeaa1920408c0127920a4c61d9ca1:

[1.5.X] Fixed #19368 -- Ensured that login error messages adapt to changes in the User model.

Thanks to un33k for the report.

Backport of 27f8129d64292868f6a328f7bf9a1bed67967ff3 from master.

comment:8 by Russell Keith-Magee <russell@…>, 12 years ago

In 9facca28b619ad94680cf07774ee7a377034ca42:

Corrected tests depending on the error message on the AuthenticationForm.

Refs #19368, and the fix introduced in 27f8129d64292868f6a328f7bf9a1bed67967ff3.

comment:9 by Russell Keith-Magee <russell@…>, 12 years ago

In 06b5f5fcb6db2fc20e2d455a34f3f4b0293cfd8c:

[1.5.X] Corrected tests depending on the error message on the AuthenticationForm.

Refs #19368, and the fix introduced in 27f8129d64292868f6a328f7bf9a1bed67967ff3.

Backport of 9facca28b619ad94680cf07774ee7a377034ca42 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top