From 8913b377e6d1011c57c28c23989fc8cfcc262184 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Fri, 14 Aug 2020 00:21:17 -0600 Subject: [PATCH] Prevent attempt at getting profile data when in dev or preview mode --- src/components/ControlBar.vue | 40 ++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/components/ControlBar.vue b/src/components/ControlBar.vue index 2344c0c..dcd9687 100644 --- a/src/components/ControlBar.vue +++ b/src/components/ControlBar.vue @@ -168,27 +168,29 @@ export default { }, mounted: function() { this.$nextTick(function() { - axios.get( - `${this.api_url}/me`, - { headers: { Authorization: `Bearer ${this.api_token}` } } - ).then((response) => { - if (response.error) { + if (!(this.preview || this.dev)) { + axios.get( + `${this.api_url}/me`, + { headers: { Authorization: `Bearer ${this.api_token}` } } + ).then((response) => { + if (response.error && !(this.preview || this.dev)) { + window.location.hash = ``; + window.location.href = `${this.auth_redirect}?error=${encodeURI(response.error)}`; + return; + }; + let data = response.data; + + // Set the Vue user object + this.user.name = data.display_name; + this.user.image = data.images.length > 0 ? data.images[0].url : ``; + + }).catch((err) => { + console.error(err) window.location.hash = ``; - window.location.href = `${this.auth_redirect}?error=${encodeURI(response.error)}`; + window.location.href = `${this.auth_redirect}?error=${encodeURI(err)}`;; return - } - let data = response.data; - - // Set the Vue user object - this.user.name = data.display_name; - this.user.image = data.images.length > 0 ? data.images[0].url : ``; - - }).catch((err) => { - console.error(err) - window.location.hash = ``; - window.location.href = `${this.auth_redirect}?error=${encodeURI(err)}`;; - return - }) + }) + }; }); } }