diff --git a/lib/homepage.py b/lib/homepage.py index 0f50a99..71234bc 100644 --- a/lib/homepage.py +++ b/lib/homepage.py @@ -291,8 +291,22 @@ def homepage(): new_pw_input = ui.input(password=True) ui.label("Neues Passwort bestätigen:") new_pw_confirm_input = ui.input(password=True) - ui.button("Speichern") - ui.button("Zurücksetzen") + def revert_pw_inputs(): + old_pw_input.value = "" + new_pw_input.value = "" + new_pw_confirm_input.value = "" + def save_new_password(): + if hash_password(old_pw_input.value) == current_user.password: + if new_pw_input.value == new_pw_confirm_input.value: + current_user.password = hash_password(new_pw_input.value) + current_user.write_settings() + ui.notify("Neues Passwort gespeichert") + else: + ui.notify("Passwortbestätigung stimmt nicht überein") + else: + ui.notify("Altes Passwort nicht korrekt") + ui.button("Speichern", on_click=save_new_password) + ui.button("Zurücksetzen", on_click=revert_pw_inputs) ui.space() else: