Verified Commit 815868da authored by Štěpán Henek's avatar Štěpán Henek 🌩

password: display how many times was the compromised password used in our lists

parent 3508685c
......@@ -220,6 +220,17 @@ class PasswordConfigPage(ConfigPageMixin, misc.PasswordHandler):
wrong_old_password = self.form.callback_results.get('wrong_old_password', False)
system_password_no_error = self.form.callback_results.get('system_password_no_error', None)
foris_password_no_error = self.form.callback_results.get('foris_password_no_error', None)
compromised = self.form.callback_results.get("compromised")
if compromised:
messages.error(
_(
"The password you've entered has been compromised. "
"It appears %(count)d times in '%(list)s' list."
) % dict(count=compromised['count'], list=compromised['list'])
)
return result
if wrong_old_password:
messages.error(_("Old password you entered was not valid."))
return result
......@@ -228,12 +239,12 @@ class PasswordConfigPage(ConfigPageMixin, misc.PasswordHandler):
if system_password_no_error:
messages.success(_("System password was successfully saved."))
else:
messages.error(_("Failed to save system password"))
messages.error(_("Failed to save system password."))
if foris_password_no_error is not None:
if foris_password_no_error:
messages.success(_("Foris password was successfully saved."))
else:
messages.error(_("Failed to save Foris password"))
messages.error(_("Failed to save Foris password."))
return result
......
......@@ -128,8 +128,15 @@ class PasswordHandler(BaseConfigHandler):
encoded_password = base64.b64encode(data["password"].encode("utf-8")).decode("utf-8")
result = current_state.backend.perform(
"password", "set", {"password": encoded_password, "type": "foris"})["result"]
passwd_result = current_state.backend.perform(
"password", "set", {"password": encoded_password, "type": "foris"})
result = passwd_result["result"]
if not result and "list" in passwd_result and "count" in passwd_result:
return "save_result", {
"compromised": {
"list": passwd_result["list"], "count": passwd_result["count"],
}
}
res = {"foris_password_no_error": result}
if data['set_system_pw'] == SYSTEM_PW_SAME:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment