Compare commits

..

3 Commits

  1. 31
      backend/utils/utils.py

@ -30,4 +30,33 @@ def is_valid_email(email):
if re.match(pattern, email):
return True
else:
return False
return False
def password_check(passwd: str) -> bool:
special_symbol_pattern = r'[$@#%]'
upper_case_pattern = r'[A-Z]'
lower_case_pattern = r'[a-z]'
digit_pattern = r'[0-9]'
if len(passwd) < 6:
raise InsecurePasswordException('Password length should be at least 6 characters.')
elif len(passwd) > 20:
raise InsecurePasswordException('Password length should not be greater than 20 characters.')
if not re.search(digit_pattern, passwd):
raise InsecurePasswordException('Password should have at least one numeral.')
if not re.search(upper_case_pattern, passwd):
raise InsecurePasswordException('Password should have at least one uppercase letter.')
if not re.search(lower_case_pattern, passwd):
raise InsecurePasswordException('Password should have at least one lowercase letter.')
if not re.search(special_symbol_pattern, passwd):
raise InsecurePasswordException('Password should have at least one of the symbols $@#%.')
return True
class InsecurePasswordException(Exception):
pass

Loading…
Cancel
Save