Disconnect the user on the frontend when the jwt token is no longer correct

This commit is contained in:
2026-03-03 19:04:41 +01:00
parent 8f5d4c21f5
commit a53c57c039
2 changed files with 8 additions and 2 deletions

View File

@@ -21,7 +21,7 @@
const appInfo = ref(null); const appInfo = ref(null);
const appInfoErr = ref(null); const appInfoErr = ref(null);
async function logInIfDemoMode(demoMode, demoUsername) { async function logInIfDemoMode(demoMode, demoUsername) {
if (!demoMode) { if (!demoMode) {
return; return;
} }

View File

@@ -28,7 +28,13 @@ function useFetch(data, error, url) {
'Authorization': 'Bearer ' + user.token 'Authorization': 'Bearer ' + user.token
} }
}) })
.then((res) => res.json()) .then((res) => {
if (res.status === 401) {
const authStore = useAuthStore();
authStore.logout();
}
return res.json();
})
.then((json) => (data.value = json)) .then((json) => (data.value = json))
.catch((err) => (error.value = err)); .catch((err) => (error.value = err));
} }