changed exception classes

manzilcheck
PANDACUSHION 6 months ago
parent af0baf7d3d
commit c733a550ec
  1. 37
      backend/utils/utils.py

@ -39,45 +39,24 @@ def password_check(passwd: str) -> bool:
digit_pattern = r'[0-9]'
if len(passwd) < 6:
raise PasswordLengthMinException('Password length should be at least 6 characters.')
raise InsecurePasswordException('Password length should be at least 6 characters.')
elif len(passwd) > 20:
raise PasswordLengthMaxException('Password length should not be greater than 20 characters.')
raise InsecurePasswordException('Password length should not be greater than 20 characters.')
if not re.search(digit_pattern, passwd):
raise PasswordNumericException('Password should have at least one numeral.')
raise InsecurePasswordException('Password should have at least one numeral.')
if not re.search(upper_case_pattern, passwd):
raise PasswordUppercaseException('Password should have at least one uppercase letter.')
raise InsecurePasswordException('Password should have at least one uppercase letter.')
if not re.search(lower_case_pattern, passwd):
raise PasswordLowercaseException('Password should have at least one lowercase letter.')
raise InsecurePasswordException('Password should have at least one lowercase letter.')
if not re.search(special_symbol_pattern, passwd):
raise PasswordSpecialSymbolException('Password should have at least one of the symbols $@#%.')
raise InsecurePasswordException('Password should have at least one of the symbols $@#%.')
return True
class PasswordLengthMinException(Exception):
def __init__(self, message):
self.message = message
class PasswordLengthMaxException(Exception):
def __init__(self, message):
self.message = message
class PasswordNumericException(Exception):
def __init__(self, message):
self.message = message
class PasswordUppercaseException(Exception):
def __init__(self, message):
self.message = message
class PasswordLowercaseException(Exception):
def __init__(self, message):
self.message = message
class PasswordSpecialSymbolException(Exception):
def __init__(self, message):
self.message = message
class InsecurePasswordException(Exception):
pass

Loading…
Cancel
Save