Add logout button.

This commit is contained in:
Roger Braun 2017-07-02 12:25:34 +02:00
parent b284689313
commit 7d59051fc5
15 changed files with 45 additions and 19 deletions

View file

@ -29,6 +29,9 @@ export default {
},
scrollToTop () {
window.scrollTo(0, 0)
},
logout () {
this.$store.dispatch('logout')
}
}
}

View file

@ -8,6 +8,7 @@
<div class='item right'>
<user-finder></user-finder>
<router-link :to="{ name: 'settings'}"><i class="icon-cog"></i></router-link>
<a href="#" v-if="currentUser" @click.prevent="logout"><i class="icon-logout" title="Logout" ></i></a>
</div>
</div>
</nav>

View file

@ -26,6 +26,9 @@ export const mutations = {
setCurrentUser (state, user) {
state.currentUser = merge(state.currentUser || {}, user)
},
clearCurrentUser (state) {
state.currentUser = false
},
beginLogin (state) {
state.loggingIn = true
},
@ -66,6 +69,11 @@ const users = {
store.commit('setUserForStatus', status)
})
},
logout (store) {
store.commit('clearCurrentUser')
store.dispatch('stopFetching', 'friends')
store.commit('setBackendInteractor', backendInteractorService())
},
loginUser (store, userCredentials) {
return new Promise((resolve, reject) => {
const commit = store.commit