Move reusable stuff to vue mixin

This commit is contained in:
Bubka
2020-10-08 14:48:18 +02:00
parent 27c7b9b880
commit 07df0cd5e0
3 changed files with 31 additions and 15 deletions

View File

@ -8,7 +8,7 @@
</div>
</div>
<div v-if="$route.name === 'settings'" class="content has-text-centered is-size-6">
<a class="has-text-grey" href="https://github.com/Bubka/2FAuth"><b>2FAuth</b> <font-awesome-icon :icon="['fab', 'github-alt']" /></a> - v{{ $root.appVersion }}
<a class="has-text-grey" href="https://github.com/Bubka/2FAuth"><b>2FAuth</b> <font-awesome-icon :icon="['fab', 'github-alt']" /></a> - v{{ appVersion }}
</div>
<div v-else class="content has-text-centered">
<router-link :to="{ name: 'settings' }" class="has-text-grey">{{ $t('settings.settings') }}</router-link> - <a class="has-text-grey" @click="logout">{{ $t('auth.sign_out') }}</a>
@ -30,21 +30,12 @@
},
methods: {
async logout(evt) {
logout() {
if(confirm(this.$t('auth.confirm.logout'))) {
await this.axios.get('api/logout')
localStorage.removeItem('jwt')
localStorage.removeItem('user')
delete this.axios.defaults.headers.common['Authorization']
this.$router.push({ name: 'login' })
this.appLogout()
}
},
}
}
};
</script>