Disconnect the user on the frontend when the jwt token is no longer correct
This commit is contained in:
@@ -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));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user