imlementation of a user management

This commit is contained in:
2026-08-25 13:29:12 +02:00
parent 7aeb325d4e
commit 7c81a7a6f6
5 changed files with 304 additions and 1 deletions
+66
View File
@@ -2064,6 +2064,72 @@ def change_email_and_resend():
return redirect(url_for("verify_account", username=username))
@app.route('/user/profile', methods=['GET', 'POST'])
def user_profile():
if 'username' not in session:
flash("Bitte melden Sie sich an, um auf Ihr Profil zuzugreifen.", "warning")
return redirect(url_for('login'))
username = session['username']
user = user_store.get_user(username)
if not user:
flash("Benutzer nicht gefunden. Bitte loggen Sie sich erneut ein.", "danger")
session.clear()
return redirect(url_for('login'))
if request.method == 'POST':
action = request.form.get('action')
if action == 'update_info':
email = request.form.get('email')
full_name = request.form.get('full_name')
user_store.update_user_profile(username, full_name, email)
session['email'] = email
session['full_name'] = full_name
flash("Ihre Profilinformationen wurden erfolgreich aktualisiert.", "success")
return redirect(url_for('user_profile'))
elif action == 'change_password':
current_password = request.form.get('current_password')
new_password = request.form.get('new_password')
confirm_password = request.form.get('confirm_password')
if not user_store.check_nm_pwd(username, current_password):
flash("Das aktuelle Passwort ist nicht korrekt.", "danger")
return redirect(url_for('user_profile'))
if new_password != confirm_password:
flash("Die neuen Passwörter stimmen nicht überein.", "danger")
return redirect(url_for('user_profile'))
if user_store.update_password(username, new_password):
flash("Ihr Passwort wurde erfolgreich geändert.", "success")
else:
flash("Das Passwort ist zu schwach. Bitte verwenden Sie mindestens 6 Zeichen.", "warning")
return redirect(url_for('user_profile'))
elif action == 'delete_account':
current_password = request.form.get('current_password')
if not user_store.check_nm_pwd(username, current_password):
flash("Das Passwort ist nicht korrekt. Konto konnte nicht gelöscht werden.", "danger")
return redirect(url_for('user_profile'))
if user_store.delete_user(username):
session.clear()
flash("Ihr Konto wurde erfolgreich gelöscht.", "info")
return redirect(url_for('default'))
else:
flash("Fehler beim Löschen des Kontos. Bitte versuchen Sie es später erneut.", "danger")
return redirect(url_for('user_profile'))
return render_template('user_profile.html', user=user)
@app.route('/download-sample')
def download_sample():
# Ensure the file is only served from the specific directory