fix: 修复校验用户密码规则

This commit is contained in:
Bai
2021-08-17 16:01:27 +08:00
committed by 老广
parent 9a541ebf05
commit d46f1080f8
5 changed files with 22 additions and 5 deletions

View File

@@ -308,7 +308,7 @@ def get_password_check_rules(user):
return check_rules
def check_password_rules(password, user):
def check_password_rules(password, is_org_admin=False):
pattern = r"^"
if settings.SECURITY_PASSWORD_UPPER_CASE:
pattern += '(?=.*[A-Z])'
@@ -319,7 +319,7 @@ def check_password_rules(password, user):
if settings.SECURITY_PASSWORD_SPECIAL_CHAR:
pattern += '(?=.*[`~!@#\$%\^&\*\(\)-=_\+\[\]\{\}\|;:\'\",\.<>\/\?])'
pattern += '[a-zA-Z\d`~!@#\$%\^&\*\(\)-=_\+\[\]\{\}\|;:\'\",\.<>\/\?]'
if user.is_org_admin:
if is_org_admin:
min_length = settings.SECURITY_ADMIN_USER_PASSWORD_MIN_LENGTH
else:
min_length = settings.SECURITY_PASSWORD_MIN_LENGTH