Просмотр исходного кода

Give "not admin" message on admin sign-in.

Rafał Pitoń 11 лет назад
Родитель
Сommit
215f50d8a6
2 измененных файлов с 10 добавлено и 3 удалено
  1. 8 3
      misago/users/forms/auth.py
  2. 2 0
      misago/users/models/usermodel.py

+ 8 - 3
misago/users/forms/auth.py

@@ -40,9 +40,14 @@ class AuthenticationForm(forms.Form, BaseAuthenticationForm):
 class AdminAuthenticationForm(AuthenticationForm):
     required_css_class = 'required'
 
+    def __init__(self, *args, **kwargs):
+        self.error_messages.update({
+            'not_staff': _("Your account does not have admin privileges.")
+            })
+
     def confirm_login_allowed(self, user):
-        if not user.is_active or not user.is_staff:
+        if not user.is_staff:
             raise forms.ValidationError(
-                self.error_messages['invalid_login'],
-                code='invalid_login',
+                self.error_messages['not_staff'],
+                code='not_staff',
             )

+ 2 - 0
misago/users/models/usermodel.py

@@ -14,6 +14,8 @@ class UserManager(BaseUserManager):
     def create_user(self, username, email, password=None, **extra_fields):
         if not email:
             raise ValueError(_("User must have an email address."))
+        if not password:
+            raise ValueError(_("User must have a password."))
 
         validate_username(username)
         validate_email(email)