Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
fix(auth): fix auth not allowing plex devices request
Browse files Browse the repository at this point in the history
  • Loading branch information
ttshivers committed Aug 27, 2020
1 parent a51670f commit 7302c00
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export default {
]),
...mapGetters('plex', [
'IS_AUTHENTICATED',
'GET_PLEX_AUTH_TOKEN',
'IS_DONE_FETCHING_DEVICES',
]),
Expand Down Expand Up @@ -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();
Expand Down
11 changes: 9 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default new Router({
path: '/signout',
component: () => import('@/views/signout.vue'),
meta: {
requiresAuth: true,
requiresPlexToken: true,
},
},

Expand Down
3 changes: 2 additions & 1 deletion src/views/signin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class="pa-4"
>
<v-alert
v-if="IS_USER_AUTHORIZED === false"
v-if="GET_PLEX_AUTH_TOKEN && IS_USER_AUTHORIZED === false"
type="error"
>
You are not authorized to access this server
Expand Down Expand Up @@ -78,6 +78,7 @@ export default {
...mapGetters('plex', [
'GET_PLEX_AUTH_URL',
'IS_USER_AUTHORIZED',
'GET_PLEX_AUTH_TOKEN',
]),
plexAuthUrl() {
Expand Down

0 comments on commit 7302c00

Please sign in to comment.