[Django] #28751: Add an error message for inactive user login in AdminAuthenticationForm

46 views
Skip to first unread message

Django

unread,
Oct 29, 2017, 3:22:18 PM10/29/17
to django-...@googlegroups.com
#28751: Add an error message for inactive user login in AdminAuthenticationForm
------------------------------------------------+------------------------
Reporter: SeungWon Kang | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
In admin login site, I found that inactive error message does not exist.
(In AuthenticationForm it exists) I know default BackEnd checks the
inactive in user_can_authenticate() method, but I think this error message
is helpful if using other BackEnd like AllowAllUsersModelBackEnd.

In AuthenticationForm,
{{{
def confirm_login_allowed(self, user):
...
if not user.is_active:
raise forms.ValidationError(
self.error_messages['inactive'],
code='inactive',
)
}}}

but in AdminAuthenticationForm,

{{{
def confirm_login_allowed(self, user):
if not user.is_active or not user.is_staff:
raise forms.ValidationError(
self.error_messages['invalid_login'],
code='invalid_login',
params={'username': self.username_field.verbose_name}
)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28751>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 29, 2017, 3:23:42 PM10/29/17
to django-...@googlegroups.com
#28751: Add an error message for inactive user login in AdminAuthenticationForm
-------------------------------------+-------------------------------------

Reporter: SeungWon Kang | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by SeungWon Kang:

Old description:

> In admin login site, I found that inactive error message does not exist.
> (In AuthenticationForm it exists) I know default BackEnd checks the
> inactive in user_can_authenticate() method, but I think this error
> message is helpful if using other BackEnd like AllowAllUsersModelBackEnd.
>
> In AuthenticationForm,
> {{{
> def confirm_login_allowed(self, user):
> ...
> if not user.is_active:
> raise forms.ValidationError(
> self.error_messages['inactive'],
> code='inactive',
> )
> }}}
>
> but in AdminAuthenticationForm,
>
> {{{
> def confirm_login_allowed(self, user):
> if not user.is_active or not user.is_staff:
> raise forms.ValidationError(
> self.error_messages['invalid_login'],
> code='invalid_login',
> params={'username': self.username_field.verbose_name}
> )
> }}}

New description:

In admin login site, I found that inactive error message does not exist.
(In AuthenticationForm it exists) I know default BackEnd checks the
inactive in user_can_authenticate() method, but I think this error message
is helpful if using other BackEnd like AllowAllUsersModelBackEnd.

In AuthenticationForm,
{{{
def confirm_login_allowed(self, user):
...
if not user.is_active:
raise forms.ValidationError(
self.error_messages['inactive'],
code='inactive',
)
}}}

but in AdminAuthenticationForm,

{{{
def confirm_login_allowed(self, user):
if not user.is_active or not user.is_staff:
raise forms.ValidationError(
self.error_messages['invalid_login'],
code='invalid_login',
params={'username': self.username_field.verbose_name}
)
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/28751#comment:1>

Django

unread,
Oct 29, 2017, 3:35:12 PM10/29/17
to django-...@googlegroups.com
#28751: Add an error message for inactive user login in AdminAuthenticationForm
-------------------------------------+-------------------------------------

Reporter: SeungWon Kang | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by SeungWon Kang:

Old description:

> In admin login site, I found that inactive error message does not exist.


> (In AuthenticationForm it exists) I know default BackEnd checks the
> inactive in user_can_authenticate() method, but I think this error
> message is helpful if using other BackEnd like AllowAllUsersModelBackEnd.
>
> In AuthenticationForm,
> {{{
> def confirm_login_allowed(self, user):
> ...
> if not user.is_active:
> raise forms.ValidationError(
> self.error_messages['inactive'],
> code='inactive',
> )
> }}}
>
> but in AdminAuthenticationForm,
>
> {{{
> def confirm_login_allowed(self, user):
> if not user.is_active or not user.is_staff:
> raise forms.ValidationError(
> self.error_messages['invalid_login'],
> code='invalid_login',
> params={'username': self.username_field.verbose_name}
> )
> }}}

New description:

In admin login site, I found that error message for 'inactive' user does


not exist. (In AuthenticationForm it exists) I know default BackEnd checks
the inactive in user_can_authenticate() method, but I think this error
message is helpful if using other BackEnd like AllowAllUsersModelBackEnd.

In AuthenticationForm,
{{{
def confirm_login_allowed(self, user):
...
if not user.is_active:
raise forms.ValidationError(
self.error_messages['inactive'],
code='inactive',
)
}}}

but in AdminAuthenticationForm,

{{{
def confirm_login_allowed(self, user):
if not user.is_active or not user.is_staff:
raise forms.ValidationError(
self.error_messages['invalid_login'],
code='invalid_login',
params={'username': self.username_field.verbose_name}
)
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/28751#comment:2>

Django

unread,
Oct 29, 2017, 10:42:36 PM10/29/17
to django-...@googlegroups.com
#28751: Add an error message for inactive user login in AdminAuthenticationForm
-------------------------------------+-------------------------------------

Reporter: SeungWon Kang | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by SeungWon Kang:

Old description:

> In admin login site, I found that error message for 'inactive' user does


> not exist. (In AuthenticationForm it exists) I know default BackEnd
> checks the inactive in user_can_authenticate() method, but I think this
> error message is helpful if using other BackEnd like
> AllowAllUsersModelBackEnd.
>
> In AuthenticationForm,
> {{{
> def confirm_login_allowed(self, user):
> ...
> if not user.is_active:
> raise forms.ValidationError(
> self.error_messages['inactive'],
> code='inactive',
> )
> }}}
>
> but in AdminAuthenticationForm,
>
> {{{
> def confirm_login_allowed(self, user):
> if not user.is_active or not user.is_staff:
> raise forms.ValidationError(
> self.error_messages['invalid_login'],
> code='invalid_login',
> params={'username': self.username_field.verbose_name}
> )
> }}}

New description:

In admin login site, I found that ValidationError message for 'inactive'
user does not exist. (In AuthenticationForm it exists) I know default
BackEnd checks the is_active in user_can_authenticate() method, but I
think adding this error message would be helpful if using other BackEnd
like AllowAllUsersModelBackEnd.

In AuthenticationForm, it shows inactive error message to the inactive
user(user that `is_active=False`)


{{{
def confirm_login_allowed(self, user):
...
if not user.is_active:
raise forms.ValidationError(
self.error_messages['inactive'],
code='inactive',
)
}}}

but in AdminAuthenticationForm, it shows invalid_login error message to
the inactive user(user that `is_active=False`)

{{{
def confirm_login_allowed(self, user):
if not user.is_active or not user.is_staff:
raise forms.ValidationError(
self.error_messages['invalid_login'],
code='invalid_login',
params={'username': self.username_field.verbose_name}
)
}}}

So I suggest to change it like

{{{
error_messages = {
...
'inactive': _("This account is inactive."),
}

...
def confirm_login_allowed(self, user):


if not user.is_active:
raise forms.ValidationError(
self.error_messages['inactive'],
code='inactive',
)

if not user.is_staff:


raise forms.ValidationError(
self.error_messages['invalid_login'],
code='invalid_login',

params = {'username': self.username_field.verbose_name},
)
....
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/28751#comment:3>

Django

unread,
Oct 30, 2017, 7:25:30 AM10/30/17
to django-...@googlegroups.com
#28751: Add an error message for inactive user login in AdminAuthenticationForm
-------------------------------------+-------------------------------------

Reporter: SeungWon Kang | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by hui shang):

[https://github.com/django/django/pull/9308 PR]

This ticket is related to [https://code.djangoproject.com/ticket/28645
ticket_28645], so I make the commits for these two tickets in the same PR.

--
Ticket URL: <https://code.djangoproject.com/ticket/28751#comment:4>

Django

unread,
Nov 1, 2017, 3:21:57 PM11/1/17
to django-...@googlegroups.com
#28751: Add an error message for inactive user login in AdminAuthenticationForm
--------------------------------------+------------------------------------

Reporter: SeungWon Kang | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* has_patch: 0 => 1
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28751#comment:5>

Django

unread,
Nov 7, 2017, 2:16:36 PM11/7/17
to django-...@googlegroups.com
#28751: Add an error message for inactive user login in AdminAuthenticationForm
--------------------------------------+------------------------------------

Reporter: SeungWon Kang | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28751#comment:6>

Django

unread,
Nov 8, 2017, 5:10:53 AM11/8/17
to django-...@googlegroups.com
#28751: Add an error message for inactive user login in AdminAuthenticationForm
--------------------------------------+------------------------------------

Reporter: SeungWon Kang | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by hui shang):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/28751#comment:7>

Django

unread,
Nov 8, 2017, 9:59:48 AM11/8/17
to django-...@googlegroups.com
#28751: Add an error message for inactive user login in AdminAuthenticationForm
--------------------------------------+------------------------------------

Reporter: SeungWon Kang | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"ebb998976e2889c669972ed3d1b372cc6a2b5229" ebb99897]:
{{{
#!CommitTicketReference repository=""
revision="ebb998976e2889c669972ed3d1b372cc6a2b5229"
Fixed #28751 -- Corrected the error message for inactive users in
AdminAuthenticationForm.

Thanks SeungWon Kang for the report and Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28751#comment:8>

Reply all
Reply to author
Forward
0 new messages