add logout handling

This commit is contained in:
2017-02-20 13:10:55 -07:00
parent 2f44aa9125
commit 8265cb7f06

View File

@@ -22,6 +22,9 @@
<router-link class="nav-item is-tab" :to="{ name: 'about' }" active-class="is-active"> <router-link class="nav-item is-tab" :to="{ name: 'about' }" active-class="is-active">
About About
</router-link> </router-link>
<a class="nav-item is-tab" @click="logout">
Logout
</a>
<span class="nav-item"> <span class="nav-item">
<a class="button" > <a class="button" >
<span class="icon"><i class="fa fa-github"></i></span> <span class="icon"><i class="fa fa-github"></i></span>
@@ -46,6 +49,12 @@
components: { components: {
TopNav, TopNav,
}, },
methods: {
logout() {
store.dispatch('userLogout')
.then(() => this.$router.push({ name: 'login' }));
}
},
// pre-route auth checking // pre-route auth checking
beforeRouteEnter(to, from, next) { beforeRouteEnter(to, from, next) {
// if user is authenticated, continue // if user is authenticated, continue