From 06fb1337140d1dcb8c8108828838c450a941230b Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 1 Aug 2025 21:18:35 +0200 Subject: [PATCH] fix --- frontend/src/utils/spotifyAuth.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/frontend/src/utils/spotifyAuth.js b/frontend/src/utils/spotifyAuth.js index 791ac68..67fc94a 100644 --- a/frontend/src/utils/spotifyAuth.js +++ b/frontend/src/utils/spotifyAuth.js @@ -13,3 +13,28 @@ export const getSpotifyLoginUrl = () => { REDIRECT_URI )}&scope=${scope}`; }; + +export const getAccessTokenFromUrl = () => { + const hash = window.location.hash; + if (hash) { + const params = new URLSearchParams(hash.substring(1)); + return params.get('access_token'); + } + return null; +}; + +export const storeAccessToken = (token) => { + localStorage.setItem('spotify_access_token', token); +}; + +export const getAccessToken = () => { + return localStorage.getItem('spotify_access_token'); +}; + +export const removeAccessToken = () => { + localStorage.removeItem('spotify_access_token'); +}; + +export const isLoggedIn = () => { + return !!getAccessToken(); +};