From 66b71208c6d2aef2ebe976bacda932172af157c1 Mon Sep 17 00:00:00 2001 From: Alexander Malzkuhn Date: Wed, 4 Jun 2025 06:25:45 +0200 Subject: [PATCH] =?UTF-8?q?Passwort=C3=A4nderungsfunktionen=20f=C3=BCrs=20?= =?UTF-8?q?User=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/homepage.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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: