Code

Opened 17 months ago

Closed 16 months ago

Last modified 16 months 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: un33k 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 un33k 17 months ago.
Admin Login with Email still warns about username
19368.patch (1.4 KB) - added by aaugustin 17 months ago.

Download all attachments as: .zip

Change History (11)

Changed 17 months ago by un33k

Admin Login with Email still warns about username

comment:1 Changed 17 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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.

Changed 17 months ago by aaugustin

comment:2 Changed 17 months ago by aaugustin

  • Has patch set
  • Triage Stage changed from Accepted to Ready 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 Changed 17 months ago by aaugustin

  • Severity changed from Normal to Release blocker

comment:4 Changed 17 months ago by ptone

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 Changed 16 months ago by russellm

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 Changed 16 months ago by Russell Keith-Magee <russell@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 27f8129d64292868f6a328f7bf9a1bed67967ff3:

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

Thanks to un33k for the report.

comment:7 Changed 16 months ago by Russell Keith-Magee <russell@…>

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 Changed 16 months ago by Russell Keith-Magee <russell@…>

In 9facca28b619ad94680cf07774ee7a377034ca42:

Corrected tests depending on the error message on the AuthenticationForm.

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

comment:9 Changed 16 months ago by Russell Keith-Magee <russell@…>

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.

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.