Changes between Version 2 and Version 3 of Ticket #28751


Ignore:
Timestamp:
Oct 29, 2017, 9:42:32 PM (7 years ago)
Author:
SeungWon Kang
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28751 – Description

    v2 v3  
    1 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.
     1In 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.
    22
    3 In AuthenticationForm,
     3In AuthenticationForm, it shows inactive error message to the inactive user(user that `is_active=False`)
    44{{{
    55    def confirm_login_allowed(self, user):
     
    1212}}}
    1313
    14 but in AdminAuthenticationForm,
     14but in AdminAuthenticationForm, it shows invalid_login error message to the inactive user(user that `is_active=False`)
    1515
    1616{{{
     
    2323            )
    2424}}}
     25
     26So I suggest to change it like
     27
     28{{{
     29error_messages = {
     30        ...
     31        'inactive': _("This account is inactive."),
     32    }
     33
     34    ...
     35    def confirm_login_allowed(self, user):
     36        if not user.is_active:
     37            raise forms.ValidationError(
     38                self.error_messages['inactive'],
     39                code='inactive',
     40            )
     41
     42        if not user.is_staff:
     43            raise forms.ValidationError(
     44                self.error_messages['invalid_login'],
     45                code='invalid_login',
     46                params = {'username': self.username_field.verbose_name},
     47            )
     48    ....
     49}}}
Back to Top