Fix auth
This commit is contained in:
parent
1f49dee177
commit
406764ea12
5 changed files with 32 additions and 46 deletions
34
src/App.vue
34
src/App.vue
|
@ -20,31 +20,25 @@ 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
|
||||
.get(
|
||||
process.env.VUE_APP_APIENDPOINT +
|
||||
|
@ -63,19 +57,13 @@ 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_APIVERSION +
|
||||
"/" +
|
||||
"awards/eligibility"
|
||||
);
|
||||
)
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
<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="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>
|
||||
</template>
|
||||
<script>
|
||||
|
@ -53,15 +54,21 @@ import AjaxErrorHandler from ".././assets/js/errorHandler";
|
|||
|
||||
export default {
|
||||
name: 'UserBadges',
|
||||
props: ['admin', 'booster', 'bot', 'hidden', 'banned', 'system', 'username', 'noPlus', 'verified'],
|
||||
props: ['admin', 'booster', 'bot', 'hidden', 'banned', 'system', 'username', 'user', 'verified', 'team'],
|
||||
data() {
|
||||
return {
|
||||
modifyUserModal: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
modal() {
|
||||
modal(type) {
|
||||
if(type === 'user') {
|
||||
this.modifyUserModal = true
|
||||
} else if(type === 'team') {
|
||||
console.log('Debug: Feature not implemented')
|
||||
} else {
|
||||
this.modifyUserModal = true
|
||||
}
|
||||
},
|
||||
modifyUser() {
|
||||
this.axios
|
||||
|
|
|
@ -32,6 +32,8 @@ Vue.use(Buefy);
|
|||
Vue.config.productionTip = false;
|
||||
Vue.prototype.$snackbar = Snackbar;
|
||||
|
||||
axios.defaults.headers.common["Authorization"] = localStorage.getItem("token")
|
||||
|
||||
// BBCode Configuration
|
||||
VMdEditor.lang.use("en-US", enUS);
|
||||
hljsTheme.extend((md, hljs) => {
|
||||
|
|
|
@ -23,23 +23,11 @@
|
|||
>
|
||||
<div class="box">
|
||||
<h1 class="title">
|
||||
{{ user.username }} <Badges
|
||||
:verified="user.verified"
|
||||
<router-link :to="'/t/' + user.username" style="text-decoration: none; color: inherit;">{{ user.username }}</router-link> <Badges
|
||||
:verified="user.verified" :team="true"
|
||||
></Badges>
|
||||
</h1>
|
||||
<img
|
||||
: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
|
||||
>
|
||||
PLACEHOLDER IMAGE<br />
|
||||
</div>
|
||||
</div>
|
||||
</Pagination>
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
:admin="user.admin"
|
||||
:booster="user.booster"
|
||||
:bot="user.bot"
|
||||
:user="true"
|
||||
></Badges>
|
||||
</h1>
|
||||
<img
|
||||
|
|
Loading…
Reference in a new issue