diff --git a/src/App.vue b/src/App.vue index 94f1cf0b..784117b3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -200,7 +200,7 @@ export default { ]), ...mapGetters('plex', [ - 'IS_AUTHENTICATED', + 'GET_PLEX_AUTH_TOKEN', 'IS_DONE_FETCHING_DEVICES', ]), @@ -304,7 +304,7 @@ export default { async created() { await this.GET_CONFIGURATION_PROMISE; - if (this.IS_AUTHENTICATED) { + if (this.GET_PLEX_AUTH_TOKEN) { // Kick off a bunch of requests that we need for later try { await this.FETCH_PLEX_USER(); diff --git a/src/main.js b/src/main.js index 65f53942..1eff1d9a 100644 --- a/src/main.js +++ b/src/main.js @@ -17,8 +17,15 @@ router.beforeEach(async (to, from, next) => { await store.dispatch('FETCH_CONFIG'); } - if (!store.getters['plex/IS_AUTHENTICATED'] - && to.matched.some((record) => record.meta.requiresAuth)) { + if (store.getters['plex/GET_PLEX_AUTH_TOKEN'] + && !store.getters['plex/IS_DONE_FETCHING_DEVICES']) { + await store.dispatch('plex/FETCH_PLEX_DEVICES_IF_NEEDED'); + } + + if ((!store.getters['plex/IS_AUTHENTICATED'] + && to.matched.some((record) => record.meta.requiresAuth)) + || (!store.getters['plex/GET_PLEX_AUTH_TOKEN'] + && to.matched.some((record) => record.meta.requiresPlexToken))) { if (to.matched.some((record) => record.meta.redirectAfterAuth)) { next({ name: 'Signin', diff --git a/src/router/index.js b/src/router/index.js index 4663f932..fae12850 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -31,7 +31,7 @@ export default new Router({ path: '/signout', component: () => import('@/views/signout.vue'), meta: { - requiresAuth: true, + requiresPlexToken: true, }, }, diff --git a/src/views/signin.vue b/src/views/signin.vue index 8a2ecbba..c1912cf9 100644 --- a/src/views/signin.vue +++ b/src/views/signin.vue @@ -13,7 +13,7 @@ class="pa-4" > You are not authorized to access this server @@ -78,6 +78,7 @@ export default { ...mapGetters('plex', [ 'GET_PLEX_AUTH_URL', 'IS_USER_AUTHORIZED', + 'GET_PLEX_AUTH_TOKEN', ]), plexAuthUrl() {