Skip to content

Commit cc5254d

Browse files
committed
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
1 parent a98b69d commit cc5254d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

frontend/src/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,20 @@ async function refresh_access_token() {
5858
logout(false);
5959
}
6060
loggedIn.value = AppState.LoggedIn;
61-
setInterval(async () => {
62-
await refresh_access_token();
63-
}, 1000 * 60 * 5);
6461
} else {
6562
localStorage.removeItem("loginKey");
6663
localStorage.removeItem("secretKey");
6764
loggedIn.value = AppState.LoggedOut;
6865
}
6966
}
7067

71-
refresh_access_token();
68+
refresh_access_token().then(() => {
69+
if (loggedIn.value === AppState.LoggedIn) {
70+
setInterval(async () => {
71+
await refresh_access_token();
72+
}, 1000 * 60 * 5);
73+
}
74+
});
7275

7376
localStorage.removeItem("secret_key");
7477

0 commit comments

Comments
 (0)