Fix auth
This commit is contained in:
parent
1f49dee177
commit
406764ea12
5 changed files with 32 additions and 46 deletions
42
src/App.vue
42
src/App.vue
|
@ -20,34 +20,28 @@ export default {
|
||||||
Footer,
|
Footer,
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
const jwt = JSON.parse(localStorage.getItem("token"));
|
if (JSON.parse(localStorage.getItem("token"))) {
|
||||||
const wind = JSON.parse(localStorage.getItem("wind404"));
|
this.$store.commit("setToken", JSON.parse(localStorage.getItem("token")));
|
||||||
|
|
||||||
if (jwt) {
|
|
||||||
this.$store.commit("setToken", jwt);
|
|
||||||
}
|
}
|
||||||
|
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, {
|
Object.assign(axios.defaults, {
|
||||||
headers: { Authorization: this.$store.state.user.token },
|
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) {
|
if (this.$store.state.debug) {
|
||||||
this.$buefy.snackbar.open({
|
this.$buefy.snackbar.open({
|
||||||
message: this.$t("errors.devBuild"),
|
message: this.$t("errors.devBuild"),
|
||||||
type: "is-warning",
|
type: "is-warning",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.axios
|
||||||
if (this.$store.state.user.username) {
|
|
||||||
this.axios
|
|
||||||
.get(
|
.get(
|
||||||
process.env.VUE_APP_APIENDPOINT +
|
process.env.VUE_APP_APIENDPOINT +
|
||||||
process.env.VUE_APP_APIVERSION +
|
process.env.VUE_APP_APIVERSION +
|
||||||
"/" +
|
"/" +
|
||||||
"userinfo"
|
"userinfo"
|
||||||
|
@ -63,20 +57,14 @@ export default {
|
||||||
this.$store.commit("setDescription", res.data.description);
|
this.$store.commit("setDescription", res.data.description);
|
||||||
this.$store.commit("setExecutive", res.data.executive);
|
this.$store.commit("setExecutive", res.data.executive);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
if (this.$store.state.user.username) {
|
||||||
this.$buefy.snackbar.open({
|
|
||||||
message: this.$t("errors.down"),
|
|
||||||
type: "is-warning",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.axios.get(
|
this.axios.get(
|
||||||
process.env.VUE_APP_APIENDPOINT +
|
process.env.VUE_APP_APIENDPOINT +
|
||||||
process.env.VUE_APP_APIVERSION +
|
process.env.VUE_APP_APIVERSION +
|
||||||
"/" +
|
"/" +
|
||||||
"awards/eligibility"
|
"awards/eligibility"
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -45,7 +45,8 @@
|
||||||
<b-tag v-if="system" class="is-success" rounded>{{ $t('badges.system') }}</b-tag>
|
<b-tag v-if="system" class="is-success" rounded>{{ $t('badges.system') }}</b-tag>
|
||||||
<b-tag v-if="hidden" rounded>{{ $t('badges.hidden') }}</b-tag>
|
<b-tag v-if="hidden" rounded>{{ $t('badges.hidden') }}</b-tag>
|
||||||
<b-tag v-if="verified" rounded><i class="fas fa-check"></i> Verified</b-tag>
|
<b-tag v-if="verified" rounded><i class="fas fa-check"></i> Verified</b-tag>
|
||||||
<b-button @click="modal()" v-if="$store.state.user.admin & !noPlus" class="is-info tag" rounded><i class="fas fa-plus"></i></b-button>
|
<b-button @click="modal(user)" v-if="$store.state.user.admin & user" class="is-info tag" rounded><i class="fas fa-plus"></i></b-button>
|
||||||
|
<b-button @click="modal(team)" v-if="$store.state.user.admin & team" class="is-info tag" rounded><i class="fas fa-plus"></i></b-button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
@ -53,15 +54,21 @@ import AjaxErrorHandler from ".././assets/js/errorHandler";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'UserBadges',
|
name: 'UserBadges',
|
||||||
props: ['admin', 'booster', 'bot', 'hidden', 'banned', 'system', 'username', 'noPlus', 'verified'],
|
props: ['admin', 'booster', 'bot', 'hidden', 'banned', 'system', 'username', 'user', 'verified', 'team'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
modifyUserModal: false
|
modifyUserModal: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
modal() {
|
modal(type) {
|
||||||
this.modifyUserModal = true
|
if(type === 'user') {
|
||||||
|
this.modifyUserModal = true
|
||||||
|
} else if(type === 'team') {
|
||||||
|
console.log('Debug: Feature not implemented')
|
||||||
|
} else {
|
||||||
|
this.modifyUserModal = true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
modifyUser() {
|
modifyUser() {
|
||||||
this.axios
|
this.axios
|
||||||
|
|
|
@ -32,6 +32,8 @@ Vue.use(Buefy);
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
Vue.prototype.$snackbar = Snackbar;
|
Vue.prototype.$snackbar = Snackbar;
|
||||||
|
|
||||||
|
axios.defaults.headers.common["Authorization"] = localStorage.getItem("token")
|
||||||
|
|
||||||
// BBCode Configuration
|
// BBCode Configuration
|
||||||
VMdEditor.lang.use("en-US", enUS);
|
VMdEditor.lang.use("en-US", enUS);
|
||||||
hljsTheme.extend((md, hljs) => {
|
hljsTheme.extend((md, hljs) => {
|
||||||
|
|
|
@ -23,23 +23,11 @@
|
||||||
>
|
>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h1 class="title">
|
<h1 class="title">
|
||||||
{{ user.username }} <Badges
|
<router-link :to="'/t/' + user.username" style="text-decoration: none; color: inherit;">{{ user.username }}</router-link> <Badges
|
||||||
:verified="user.verified"
|
:verified="user.verified" :team="true"
|
||||||
></Badges>
|
></Badges>
|
||||||
</h1>
|
</h1>
|
||||||
<img
|
PLACEHOLDER IMAGE<br />
|
||||||
:src="
|
|
||||||
'https://cdn.kaverti.com/user/avatars/full/' +
|
|
||||||
user.picture +
|
|
||||||
'.png'
|
|
||||||
"
|
|
||||||
/><br />
|
|
||||||
<b-button
|
|
||||||
tag="router-link"
|
|
||||||
:to="'/u/' + user.username"
|
|
||||||
class="is-centered is-info"
|
|
||||||
>View Team</b-button
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Pagination>
|
</Pagination>
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
:admin="user.admin"
|
:admin="user.admin"
|
||||||
:booster="user.booster"
|
:booster="user.booster"
|
||||||
:bot="user.bot"
|
:bot="user.bot"
|
||||||
|
:user="true"
|
||||||
></Badges>
|
></Badges>
|
||||||
</h1>
|
</h1>
|
||||||
<img
|
<img
|
||||||
|
|
Loading…
Reference in a new issue