mirror of
https://github.com/KevinMidboe/seasoned.git
synced 2026-03-11 11:55:38 +00:00
Fix: Add localStorage fallback for Plex authentication checks
Issue: ActivityPage and route guards showed "not authenticated" even when Plex was linked via Settings page. Root cause: Plex user data stored in localStorage but route guards and ActivityPage only checked Vuex store (state.settings.plexUserId). Changes: - Update routes.ts hasPlexAccount() to check both: 1. Vuex store (user/plexUserId) 2. localStorage (plex_user_data) as fallback - Update ActivityPage plexUserId computed to check both: 1. Vuex store first 2. localStorage plex_user_data.id as fallback Why two sources? - Vuex store: Set from JWT token (backend user settings) - localStorage: Set immediately when linking Plex account - localStorage persists across page reloads - Provides seamless experience without backend round-trip Now Activity page correctly shows data when Plex is linked ✓
This commit is contained in:
@@ -132,7 +132,25 @@
|
||||
|
||||
const days: Ref<number> = ref(30);
|
||||
const graphViewMode: Ref<GraphTypes> = ref(GraphTypes.Plays);
|
||||
const plexUserId = computed(() => store.getters["user/plexUserId"]);
|
||||
|
||||
// Check both Vuex store and localStorage for Plex user
|
||||
const plexUserId = computed(() => {
|
||||
// First try Vuex store
|
||||
const storeId = store.getters["user/plexUserId"];
|
||||
if (storeId) return storeId;
|
||||
|
||||
// Fallback to localStorage
|
||||
const userData = localStorage.getItem("plex_user_data");
|
||||
if (userData) {
|
||||
try {
|
||||
return JSON.parse(userData).id;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const plexUsername = computed(() => {
|
||||
const userData = localStorage.getItem("plex_user_data");
|
||||
if (userData) {
|
||||
|
||||
Reference in New Issue
Block a user