mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-22 08:13:11 +01:00
Move reusable stuff to vue mixin
This commit is contained in:
parent
27c7b9b880
commit
07df0cd5e0
3
resources/js/app.js
vendored
3
resources/js/app.js
vendored
@ -15,8 +15,7 @@ Vue.use(Notifications)
|
||||
const app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
appSettings: window.appSettings,
|
||||
appVersion: window.appVersion
|
||||
appSettings: window.appSettings
|
||||
},
|
||||
components: { App },
|
||||
i18n,
|
||||
|
@ -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>
|
||||
|
26
resources/js/mixins.js
vendored
Normal file
26
resources/js/mixins.js
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
Vue.mixin({
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
appVersion: window.appVersion
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
async appLogout(evt) {
|
||||
|
||||
await this.axios.get('api/logout')
|
||||
|
||||
localStorage.removeItem('jwt')
|
||||
localStorage.removeItem('user')
|
||||
|
||||
delete this.axios.defaults.headers.common['Authorization']
|
||||
|
||||
this.$router.push({ name: 'login' })
|
||||
},
|
||||
}
|
||||
|
||||
})
|
Loading…
Reference in New Issue
Block a user