modified: app.py

This commit is contained in:
SimolZimol
2024-10-27 11:43:30 +01:00
parent e96da0f08f
commit b31fc22d82

13
app.py
View File

@@ -295,6 +295,9 @@ def user_dashboard(guild_id):
if g.user_info: if g.user_info:
user_id = g.user_info["id"] user_id = g.user_info["id"]
# Debugging-Ausgaben
print(f"Accessing user_dashboard for user_id: {user_id}, guild_id: {guild_id}")
# Hole die serverbezogenen Nutzerdaten # Hole die serverbezogenen Nutzerdaten
connection = get_db_connection() connection = get_db_connection()
cursor = connection.cursor(dictionary=True) cursor = connection.cursor(dictionary=True)
@@ -303,17 +306,25 @@ def user_dashboard(guild_id):
cursor.execute("SELECT * FROM user_data WHERE user_id = %s AND guild_id = %s", (user_id, guild_id)) cursor.execute("SELECT * FROM user_data WHERE user_id = %s AND guild_id = %s", (user_id, guild_id))
user_data = cursor.fetchone() user_data = cursor.fetchone()
# Debugging-Ausgabe für user_data
print(f"user_data for user_id {user_id} on guild_id {guild_id}: {user_data}")
cursor.close() cursor.close()
connection.close() connection.close()
if user_data: if user_data:
g.guild_id = guild_id # Setzt g.guild_id für die Navigation # Falls `user_data` vorhanden ist, setze `g.guild_id` und `g.user_data`
g.guild_id = guild_id
g.user_data = user_data g.user_data = user_data
return render_template("user_dashboard.html") return render_template("user_dashboard.html")
else: else:
# Debugging-Ausgabe für Fehlerfall
print(f"No access for user_id {user_id} on guild_id {guild_id}")
flash("You do not have access to this server.", "danger") flash("You do not have access to this server.", "danger")
return redirect(url_for("user_landing_page")) return redirect(url_for("user_landing_page"))
# Falls der Benutzer nicht eingeloggt ist
print("User not logged in, redirecting to landing page.")
flash("Please log in to view your dashboard.", "danger") flash("Please log in to view your dashboard.", "danger")
return redirect(url_for("landing_page")) return redirect(url_for("landing_page"))