Disconnect the user on the frontend when the jwt token is no longer correct
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
const appInfo = ref(null);
|
||||
const appInfoErr = ref(null);
|
||||
|
||||
async function logInIfDemoMode(demoMode, demoUsername) {
|
||||
async function logInIfDemoMode(demoMode, demoUsername) {
|
||||
if (!demoMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,13 @@ function useFetch(data, error, url) {
|
||||
'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))
|
||||
.catch((err) => (error.value = err));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user