From 406764ea120fff96ee363834344d8e4667b4d6e9 Mon Sep 17 00:00:00 2001 From: Troplo Date: Fri, 9 Apr 2021 19:59:33 +1000 Subject: [PATCH] Fix auth --- src/App.vue | 42 ++++++++++++++------------------------- src/components/Badges.vue | 15 ++++++++++---- src/main.js | 2 ++ src/views/Teams.vue | 18 +++-------------- src/views/Users.vue | 1 + 5 files changed, 32 insertions(+), 46 deletions(-) diff --git a/src/App.vue b/src/App.vue index b225f00..a4a9206 100644 --- a/src/App.vue +++ b/src/App.vue @@ -20,34 +20,28 @@ export default { Footer, }, mounted() { - const jwt = JSON.parse(localStorage.getItem("token")); - const wind = JSON.parse(localStorage.getItem("wind404")); - - if (jwt) { - this.$store.commit("setToken", jwt); + if (JSON.parse(localStorage.getItem("token"))) { + this.$store.commit("setToken", JSON.parse(localStorage.getItem("token"))); } - + if (JSON.parse(localStorage.getItem("wind404"))) { + var wind = JSON.parse(localStorage.getItem("wind404")); + } else { + // eslint-disable-next-line no-redeclare + var wind = false; + } + this.$store.commit("setWind", wind); Object.assign(axios.defaults, { headers: { Authorization: this.$store.state.user.token }, }); - - if (wind) { - this.$store.commit("setWind", wind); - } else { - this.$store.commit("setWind", wind); - } - if (this.$store.state.debug) { this.$buefy.snackbar.open({ message: this.$t("errors.devBuild"), type: "is-warning", }); } - - if (this.$store.state.user.username) { - this.axios + this.axios .get( - process.env.VUE_APP_APIENDPOINT + + process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + "/" + "userinfo" @@ -63,20 +57,14 @@ export default { this.$store.commit("setDescription", res.data.description); this.$store.commit("setExecutive", res.data.executive); }) - .catch(() => { - this.$buefy.snackbar.open({ - message: this.$t("errors.down"), - type: "is-warning", - }); - }); - + if (this.$store.state.user.username) { this.axios.get( - process.env.VUE_APP_APIENDPOINT + + process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + "/" + "awards/eligibility" - ); - } + ) + } }, }; diff --git a/src/components/Badges.vue b/src/components/Badges.vue index fb269f2..3910f59 100644 --- a/src/components/Badges.vue +++ b/src/components/Badges.vue @@ -45,7 +45,8 @@ {{ $t('badges.system') }}  {{ $t('badges.hidden') }}   Verified - + +