rough session timeout
This commit is contained in:
15
Seasoned.Frontend/app/plugins/auth-watch.ts
Normal file
15
Seasoned.Frontend/app/plugins/auth-watch.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
const showTimeout = useState('showSessionTimeout', () => false);
|
||||
const isLoggedIn = useState('isLoggedIn');
|
||||
|
||||
nuxtApp.hooks.hook('app:suspense:resolve', () => {
|
||||
globalThis.$fetch = $fetch.create({
|
||||
onResponseError({ response }) {
|
||||
if (response.status === 401 && isLoggedIn.value) {
|
||||
isLoggedIn.value = false;
|
||||
showTimeout.value = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user