From c733a550ec4f8b197d92f2ad3a759141146d7799 Mon Sep 17 00:00:00 2001 From: PANDACUSHION Date: Sat, 11 Jan 2025 16:15:48 +0545 Subject: [PATCH] changed exception classes --- backend/utils/utils.py | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/backend/utils/utils.py b/backend/utils/utils.py index eeac0c5..3b23166 100644 --- a/backend/utils/utils.py +++ b/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