refactor: PEP20 flat is better than nested

This commit is contained in:
Éloi Rivard 2024-11-20 14:26:05 +01:00
parent cd398ffa0a
commit b0e38b6f71
No known key found for this signature in database
GPG key ID: 7EDA204EA57DD184

View file

@ -88,16 +88,16 @@ def password_strength_calculator(password):
def compromised_password_validator(form, field):
if current_app.config["CANAILLE"]["ENABLE_PASSWORD_COMPROMISSION_CHECK"]:
if not current_app.config["CANAILLE"]["ENABLE_PASSWORD_COMPROMISSION_CHECK"]:
return None
hashed_password = hashlib.sha1(field.data.encode("utf-8")).hexdigest()
hashed_password_prefix, hashed_password_suffix = (
hashed_password[:5].upper(),
hashed_password[5:].upper(),
)
api_url = (
current_app.config["CANAILLE"]["API_URL_HIBP"] + hashed_password_prefix
)
api_url = current_app.config["CANAILLE"]["API_URL_HIBP"] + hashed_password_prefix
try:
response = requests.api.get(api_url, timeout=10)
@ -118,8 +118,6 @@ def compromised_password_validator(form, field):
"This password appears on public compromission databases and is not secure."
)
)
else:
return None
def email_validator(form, field):