From 34d79dfc6400f1386725f55ddd59b3f1120910a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Wed, 27 Feb 2019 10:45:46 +0100 Subject: [PATCH] Log out the user if fetchUser was unsuccessful --- store/auth.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/store/auth.js b/store/auth.js index a2b53a196..91baad151 100644 --- a/store/auth.js +++ b/store/auth.js @@ -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