Log out the user if fetchUser was unsuccessful

This commit is contained in:
Robert Schäfer 2019-02-27 10:45:46 +01:00
parent fba1072964
commit 34d79dfc64

View File

@ -67,7 +67,7 @@ export const actions = {
}
return getters.isLoggedIn
},
async fetchCurrentUser({ commit }) {
async fetchCurrentUser({ commit, dispatch }) {
const client = this.app.apolloProvider.defaultClient
const {
data: { currentUser }
@ -83,6 +83,7 @@ export const actions = {
}
}`)
})
if (!currentUser) return dispatch('logout')
const { token, ...user } = currentUser
commit('SET_USER', user)
return user