Browse Source

Dropped extra password requirements #275

Rafał Pitoń 11 years ago
parent
commit
1100e448cb

+ 0 - 14
misago/users/migrations/0002_db_settings.py

@@ -77,20 +77,6 @@ class Migration(DataMigration):
                         },
                         },
                     },
                     },
                     {
                     {
-                        'setting': 'password_complexity',
-                        'name': _("Complexity"),
-                        'python_type': 'list',
-                        'value': [],
-                        'form_field': 'checkbox',
-                        'field_extra': {
-                            'choices': (
-                                ('case', _("Require mixed Case")),
-                                ('alphanumerics', _("Require alphanumeric characters")),
-                                ('special', _("Require special characters"))
-                            ),
-                        },
-                    },
-                    {
                         'setting': 'avatars_types',
                         'setting': 'avatars_types',
                         'name': _("Available avatar types"),
                         'name': _("Available avatar types"),
                         'legend': _("Avatars"),
                         'legend': _("Avatars"),

+ 4 - 40
misago/users/tests/test_validators.py

@@ -5,10 +5,6 @@ from django.test import TestCase
 from misago.conf import settings
 from misago.conf import settings
 from misago.users.validators import (validate_email, validate_email_available,
 from misago.users.validators import (validate_email, validate_email_available,
                                      validate_password,
                                      validate_password,
-                                     validate_password_length,
-                                     _validate_password_alphanumerics,
-                                     _validate_password_case,
-                                     _validate_password_special,
                                      validate_username,
                                      validate_username,
                                      validate_username_available,
                                      validate_username_available,
                                      validate_username_content,
                                      validate_username_content,
@@ -41,46 +37,14 @@ class ValidateEmailTests(TestCase):
 
 
 
 
 class ValidatePasswordTests(TestCase):
 class ValidatePasswordTests(TestCase):
-    def test_validate_password(self):
-        """validate_password has no crashes"""
-        validate_password('Bobbins.1')
-        with self.assertRaises(ValidationError):
-            validate_password('b')
-
-
-class ValidatePasswordLengthTests(TestCase):
     def test_valid_password(self):
     def test_valid_password(self):
-        """validate_password_length allows valid password"""
-        validate_password_length('A' * (settings.password_length_min + 1))
+        """validate_password allows valid password"""
+        validate_password('A' * (settings.password_length_min + 1))
 
 
     def test_invalid_name(self):
     def test_invalid_name(self):
-        """validate_password_length disallows invalid password"""
-        with self.assertRaises(ValidationError):
-            validate_password_length('A' * (settings.password_length_min - 1))
-
-
-class ValidatePasswordComplexityRules(TestCase):
-    def test_validate_password_alphanumerics(self):
-        """_validate_password_alphanumerics enforces complexity correctly"""
-        _validate_password_alphanumerics('abc123')
-        with self.assertRaises(ValidationError):
-            _validate_password_alphanumerics('abc')
-        with self.assertRaises(ValidationError):
-            _validate_password_alphanumerics('123')
-
-    def test_validate_password_case(self):
-        """_validate_password_case enforces complexity correctly"""
-        _validate_password_case('AbC')
-        with self.assertRaises(ValidationError):
-            _validate_password_case('abc')
-        with self.assertRaises(ValidationError):
-            _validate_password_case('--')
-
-    def test_validate_password_special(self):
-        """_validate_password_special enforces complexity correctly"""
-        _validate_password_special(u'łoł12 3&(#@$')
+        """validate_password disallows invalid password"""
         with self.assertRaises(ValidationError):
         with self.assertRaises(ValidationError):
-            _validate_password_special('A')
+            validate_password('A' * (settings.password_length_min - 1))
 
 
 
 
 class ValidateUsernameTests(TestCase):
 class ValidateUsernameTests(TestCase):

+ 1 - 47
misago/users/validators.py

@@ -6,7 +6,6 @@ from django.contrib.auth import get_user_model
 from misago.conf import settings
 from misago.conf import settings
 
 
 
 
-ALPHANUMERICS_RE = re.compile('[\W_]+', re.UNICODE)
 USERNAME_RE = re.compile(r'^[0-9a-z]+$', re.IGNORECASE)
 USERNAME_RE = re.compile(r'^[0-9a-z]+$', re.IGNORECASE)
 
 
 
 
@@ -32,46 +31,7 @@ def validate_email(value):
     validate_email_banned(value)
     validate_email_banned(value)
 
 
 
 
-def _validate_password_alphanumerics(value):
-    digits_len = len(filter(type(value).isdigit, value))
-
-    if not digits_len or digits_len == len(value):
-        raise ValidationError(
-            _("Password must contain digits in addition to other characters."))
-
-
-def _validate_password_case(value):
-    for char in value:
-        if char != char.lower():
-            break
-    else:
-        raise ValidationError(
-            _("Password must contain characters with different cases."))
-
-
-
-def _validate_password_special(value):
-    alphanumerics_len = len(ALPHANUMERICS_RE.sub('', value))
-
-    if not alphanumerics_len or alphanumerics_len == len(value):
-        raise ValidationError(
-            _("Password must contain special signs "
-              "in addition to other characters."))
-
-
-PASSWORD_COMPLEXITY_RULES = {
-    'alphanumerics': _validate_password_alphanumerics,
-    'case': _validate_password_case,
-    'special': _validate_password_special,
-}
-
-
-def validate_password_complexity(value):
-    for test in settings.password_complexity:
-        PASSWORD_COMPLEXITY_RULES[test](value)
-
-
-def validate_password_length(value):
+def validate_password(value):
     if len(value) < settings.password_length_min:
     if len(value) < settings.password_length_min:
         message = ungettext(
         message = ungettext(
             'Valid password must be at least one character long.',
             'Valid password must be at least one character long.',
@@ -81,12 +41,6 @@ def validate_password_length(value):
         raise ValidationError(message)
         raise ValidationError(message)
 
 
 
 
-def validate_password(value):
-    """shortcut function that does complete validation of password"""
-    validate_password_length(value)
-    validate_password_complexity(value)
-
-
 def validate_username_available(value):
 def validate_username_available(value):
     User = get_user_model()
     User = get_user_model()