From 268e9ce5042cc89707204153b64f04f1c1b9e0e0 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 19 Jun 2019 23:11:39 -0400
Subject: [PATCH] make sure to clear old token when logout
---
src/lib/persisted_state.js | 3 ++-
src/modules/oauth.js | 4 ++++
src/modules/users.js | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/lib/persisted_state.js b/src/lib/persisted_state.js
index 7ab89c12..cad7ea25 100644
--- a/src/lib/persisted_state.js
+++ b/src/lib/persisted_state.js
@@ -19,7 +19,8 @@ const saveImmedeatelyActions = [
'setHighlight',
'setOption',
'setClientData',
- 'setToken'
+ 'setToken',
+ 'clearToken'
]
const defaultStorage = (() => {
diff --git a/src/modules/oauth.js b/src/modules/oauth.js
index 11cb10fe..b7755b64 100644
--- a/src/modules/oauth.js
+++ b/src/modules/oauth.js
@@ -22,6 +22,10 @@ const oauth = {
},
setToken (state, token) {
state.userToken = token
+ },
+ clearToken (state) {
+ state.userToken = false
+ state.token = false
}
},
getters: {
diff --git a/src/modules/users.js b/src/modules/users.js
index 22340271..1e0b16f5 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -399,7 +399,7 @@ const users = {
logout (store) {
store.commit('clearCurrentUser')
store.dispatch('disconnectFromChat')
- store.commit('setToken', false)
+ store.commit('clearToken')
store.dispatch('stopFetching', 'friends')
store.commit('setBackendInteractor', backendInteractorService(store.getters.getToken()))
store.dispatch('stopFetching', 'notifications')