Пример #1
0
 def validate(self, password, user=None):
     if self.get_digits_count(password) < self.min_digits:
         raise PasswordInsecureValidationError(
             message="The password must contain at least {} digit(s).".
             format(self.min_digits),
             code=self.code,
             params={'min_digits': self.min_digits},
         )
Пример #2
0
 def validate(self, password, user=None):
     if len(password) < self.min_length:
         raise PasswordInsecureValidationError(
             message="The password must contain at least {} character(s).".
             format(self.min_length),
             code=self.code,
             params={'min_length': self.min_length},
         )
Пример #3
0
 def validate(self, password, user=None):
     if self.get_lower_count(password) < self.min_lower:
         raise PasswordInsecureValidationError(
             message=
             "The password must contain at least {} lower character(s).".
             format(self.min_lower),
             code=self.code,
             params={'min_lower': self.min_lower},
         )
Пример #4
0
 def validate(self, password, user=None):
     if self.get_special_count(password) < self.min_special:
         raise PasswordInsecureValidationError(
             message=(
                 "The password must contain at least {min_special} special"
                 " character(s) from these : {special_list}").format(
                     min_special=self.min_special,
                     special_list=settings.SPECIAL_CHARACTERS,
                 ),
             code=self.code,
             params={'min_special': self.min_special},
         )
 def __call__(self, value):
     try:
         for validator in settings.AUTH_PASSWORD_VALIDATORS:
             module_name, validator_name = validator['NAME'].rsplit('.', 1)
             module = import_module(module_name)
             validator_cls = getattr(module, validator_name)
             validator_cls().validate(value)
     except PasswordInsecureValidationError:
         raise
     except Exception as e:
         raise PasswordInsecureValidationError(str(e),
                                               code='PASSWORD_INSECURE')