Skip to content

A self-hosted media server and file management system

Handle session expiry

aminnausin0a7fbdecc449
diff --git a/resources/js/stores/AuthStore.js b/resources/js/stores/AuthStore.js
index 7ade44b7..a9846e4b 100644
--- a/resources/js/stores/AuthStore.js
+++ b/resources/js/stores/AuthStore.js
@@ -23,9 +23,9 @@ export const useAuthStore = defineStore('Auth', () => {
try {
const localToken = localStorage.getItem('auth-token');
- const { data, error } = await authenticate(localToken)
+ const { data, error, status } = await authenticate(localToken)
- if(error){ // Auth request was denied (so local data is invalid) -> don't logout because that will be another 401 anyway
+ if(error || status !== 200){ // Auth request was denied (so local data is invalid) -> don't logout because that will be another 401 anyway
throw error ?? 'Unauthenticated';
}
@@ -33,6 +33,7 @@ export const useAuthStore = defineStore('Auth', () => {
return true;
} catch (error) {
console.log(error);
+ toastr.error('Session Expired, Unable to Log In');
clearAuthState();
return false;
}
diff --git a/resources/js/stores/ContentStore.js b/resources/js/stores/ContentStore.js
index b4dfe8dd..d1b05703 100644
--- a/resources/js/stores/ContentStore.js
+++ b/resources/js/stores/ContentStore.js
@@ -131,7 +131,10 @@ export const useContentStore = defineStore('Content', () => {
}
function playlistFind(id){
- stateVideo.value = statePlaylist.value.find((video) => { return video.id === id});
+ stateVideo.value = statePlaylist.value.find((video) => {
+ console.log('found id ' + (video?.id ?? 'null'));
+ return video.id === id
+ });
}
// InitPlaylist (set up playlist with indexes and current video)