Opened 7 years ago

Last modified 7 years ago

#28751 closed Cleanup/optimization

Add an error message for inactive user login in AdminAuthenticationForm — at Version 1

Reported by: SeungWon Kang Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by SeungWon Kang)

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}
            )

Change History (1)

comment:1 by SeungWon Kang, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top