From cc5254dfbb6c1874572c48da82f6dd3183b5a086 Mon Sep 17 00:00:00 2001 From: Frederic Henrichs Date: Fri, 18 Oct 2024 15:10:15 +0200 Subject: [PATCH] frontend: fix adding another timeout to refresh the access token which leads to multiple requests beeing send with the same refresh token which then logs the user out. Fix #117 --- frontend/src/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index bf1fb66..ffdbde5 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -58,9 +58,6 @@ async function refresh_access_token() { logout(false); } loggedIn.value = AppState.LoggedIn; - setInterval(async () => { - await refresh_access_token(); - }, 1000 * 60 * 5); } else { localStorage.removeItem("loginKey"); localStorage.removeItem("secretKey"); @@ -68,7 +65,13 @@ async function refresh_access_token() { } } -refresh_access_token(); +refresh_access_token().then(() => { + if (loggedIn.value === AppState.LoggedIn) { + setInterval(async () => { + await refresh_access_token(); + }, 1000 * 60 * 5); + } +}); localStorage.removeItem("secret_key");