forked from Github-Mirrors/canaille
refactor: PEP20 flat is better than nested
This commit is contained in:
parent
b0e38b6f71
commit
6fa86cb5b2
1 changed files with 38 additions and 33 deletions
|
@ -6,41 +6,46 @@ from canaille.core.mails import send_compromised_password_check_failure_mail
|
||||||
|
|
||||||
|
|
||||||
def check_if_send_mail_to_admins(form, api_url, hashed_password_suffix):
|
def check_if_send_mail_to_admins(form, api_url, hashed_password_suffix):
|
||||||
if current_app.features.has_smtp and current_app.config["CANAILLE"]["ADMIN_EMAIL"]:
|
if (
|
||||||
|
not current_app.features.has_smtp
|
||||||
|
or not current_app.config["CANAILLE"]["ADMIN_EMAIL"]
|
||||||
|
):
|
||||||
|
return
|
||||||
|
|
||||||
|
flash(
|
||||||
|
_(
|
||||||
|
"Password compromise investigation failed. "
|
||||||
|
"Please contact the administrators."
|
||||||
|
),
|
||||||
|
"error",
|
||||||
|
)
|
||||||
|
|
||||||
|
if form.user is not None:
|
||||||
|
user_name = form.user.user_name
|
||||||
|
user_email = form.user.emails[0]
|
||||||
|
else:
|
||||||
|
user_name = form["user_name"].data
|
||||||
|
user_email = form["emails"].data[0]
|
||||||
|
|
||||||
|
if send_compromised_password_check_failure_mail(
|
||||||
|
api_url,
|
||||||
|
user_name,
|
||||||
|
user_email,
|
||||||
|
hashed_password_suffix,
|
||||||
|
current_app.config["CANAILLE"]["ADMIN_EMAIL"],
|
||||||
|
):
|
||||||
flash(
|
flash(
|
||||||
_(
|
_(
|
||||||
"Password compromise investigation failed. "
|
"We have informed your administrator about the failure of the password compromise investigation."
|
||||||
"Please contact the administrators."
|
),
|
||||||
|
"info",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
flash(
|
||||||
|
_(
|
||||||
|
"An error occurred while communicating the incident to the administrators. "
|
||||||
|
"Please update your password as soon as possible. "
|
||||||
|
"If this still happens, please contact the administrators."
|
||||||
),
|
),
|
||||||
"error",
|
"error",
|
||||||
)
|
)
|
||||||
|
|
||||||
if form.user is not None:
|
|
||||||
user_name = form.user.user_name
|
|
||||||
user_email = form.user.emails[0]
|
|
||||||
else:
|
|
||||||
user_name = form["user_name"].data
|
|
||||||
user_email = form["emails"].data[0]
|
|
||||||
|
|
||||||
if send_compromised_password_check_failure_mail(
|
|
||||||
api_url,
|
|
||||||
user_name,
|
|
||||||
user_email,
|
|
||||||
hashed_password_suffix,
|
|
||||||
current_app.config["CANAILLE"]["ADMIN_EMAIL"],
|
|
||||||
):
|
|
||||||
flash(
|
|
||||||
_(
|
|
||||||
"We have informed your administrator about the failure of the password compromise investigation."
|
|
||||||
),
|
|
||||||
"info",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
flash(
|
|
||||||
_(
|
|
||||||
"An error occurred while communicating the incident to the administrators. "
|
|
||||||
"Please update your password as soon as possible. "
|
|
||||||
"If this still happens, please contact the administrators."
|
|
||||||
),
|
|
||||||
"error",
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in a new issue