From 319370a3ff6dc7218c1bd930ddec952336592336 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Mon, 17 Aug 2020 23:43:51 -0600 Subject: [PATCH] Accept the error object in the auth expiration function --- src/components/ControlBar.vue | 4 ++-- src/components/MainView.vue | 4 ++-- src/components/modals/DetailedTrack.vue | 4 ++-- src/components/modals/PlaylistExport.vue | 8 ++++---- src/main.js | 8 ++++++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/components/ControlBar.vue b/src/components/ControlBar.vue index d096d0c..fcc0a74 100644 --- a/src/components/ControlBar.vue +++ b/src/components/ControlBar.vue @@ -182,8 +182,8 @@ export default { this.$emit(`user_id`, data.id); }).catch((err) => { - if (err.status == 401) { - this.auth_expired(); + if (err.response.status == 401) { + return this.auth_expired(err); }; }) }; diff --git a/src/components/MainView.vue b/src/components/MainView.vue index 09fa4ae..530478a 100644 --- a/src/components/MainView.vue +++ b/src/components/MainView.vue @@ -83,8 +83,8 @@ export default { this.data = response.data.items; }).catch((err) => { this.error = `${err.name}: ${err.message}`; - if (err.status == 401) { - this.auth_expired(); + if (err.response.status == 401) { + return this.auth_expired(err); }; }); }, diff --git a/src/components/modals/DetailedTrack.vue b/src/components/modals/DetailedTrack.vue index fc6cb6d..db7456c 100644 --- a/src/components/modals/DetailedTrack.vue +++ b/src/components/modals/DetailedTrack.vue @@ -104,8 +104,8 @@ export default { this.data_populated = true; }) .catch(err => { - if (err.status == 401) { - this.auth_expired(); + if (err.response.status == 401) { + return this.auth_expired(err); }; }); }) diff --git a/src/components/modals/PlaylistExport.vue b/src/components/modals/PlaylistExport.vue index 07a90f9..1d3b6c8 100644 --- a/src/components/modals/PlaylistExport.vue +++ b/src/components/modals/PlaylistExport.vue @@ -136,8 +136,8 @@ export default { this.populate_playlist() }) .catch((err) => { - if (err.status == 401) { - this.auth_expired(); + if (err.response.status == 401) { + return this.auth_expired(err); }; }) }, @@ -161,8 +161,8 @@ export default { this.success = true; }) .catch((err) => { - if (err.status == 401) { - this.auth_expired(); + if (err.response.status == 401) { + return this.auth_expired(err); }; }) }, diff --git a/src/main.js b/src/main.js index 778d586..30bbcab 100644 --- a/src/main.js +++ b/src/main.js @@ -35,10 +35,14 @@ Vue.mixin({ css_var(var_name) { return getComputedStyle(document.documentElement).getPropertyValue(var_name); }, - auth_expired() { + auth_expired(error = null) { sessionStorage.removeItem(this.storage_key.token); window.location.hash = ``; - window.location.href = this.auth_redirect; + if (error) { + window.location.href = `${this.home_page}?error=${error}`; + } else { + window.location.href = this.home_page; + }; }, }, });