forked from Github-Mirrors/canaille
refactor: PEP20 flat is better than nested
This commit is contained in:
parent
cd398ffa0a
commit
b0e38b6f71
1 changed files with 29 additions and 31 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue