From f3475150816ed1d7b1ff9f137d8c236cef364af1 Mon Sep 17 00:00:00 2001 From: SimolZimol <70102430+SimolZimol@users.noreply.github.com> Date: Mon, 19 May 2025 20:03:12 +0200 Subject: [PATCH] modified: app.py modified: locales/de-DE.json modified: locales/en-EN.json modified: templates/playlists.html --- app.py | 10 ++++++++-- locales/de-DE.json | 3 ++- locales/en-EN.json | 3 ++- templates/playlists.html | 3 +++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index aa4db6b..e0d0daa 100644 --- a/app.py +++ b/app.py @@ -103,6 +103,12 @@ def callback(): code = request.args.get('code') token_info = sp_oauth.get_access_token(code) session["token_info"] = token_info + + # Hole User-Infos und speichere sie in der Session + sp = spotipy.Spotify(auth=token_info['access_token']) + user = sp.current_user() + session["user"] = user + return redirect("/playlists") @app.route("/playlists") @@ -266,8 +272,8 @@ def toggle_playback(): @app.route('/logout') def logout(): - session.pop('user', None) - return redirect(url_for('index')) + session.clear() + return redirect(url_for('home')) @app.route('/') def index(): diff --git a/locales/de-DE.json b/locales/de-DE.json index 61689ef..70e82d1 100644 --- a/locales/de-DE.json +++ b/locales/de-DE.json @@ -36,5 +36,6 @@ "artist": "Künstler", "album": "Album", "year": "Jahr", - "open_on_spotify": "Auf Spotify öffnen" + "open_on_spotify": "Auf Spotify öffnen", + "logout": "Abmelden" } \ No newline at end of file diff --git a/locales/en-EN.json b/locales/en-EN.json index 18b18af..3bbc3bd 100644 --- a/locales/en-EN.json +++ b/locales/en-EN.json @@ -36,5 +36,6 @@ "artist": "Artist", "album": "Album", "year": "Year", - "open_on_spotify": "Open on Spotify" + "open_on_spotify": "Open on Spotify", + "logout": "Logout" } \ No newline at end of file diff --git a/templates/playlists.html b/templates/playlists.html index c42fc27..5609b73 100644 --- a/templates/playlists.html +++ b/templates/playlists.html @@ -54,6 +54,9 @@ + + {{ translations['logout'] if translations['logout'] else 'Logout' }} +

{{ translations['choose_playlist'] }}