|
@@ -25,6 +25,13 @@ const mutations = {
|
|
|
},
|
|
|
SET_ROLES: (state, roles) => {
|
|
|
state.roles = roles
|
|
|
+ },
|
|
|
+
|
|
|
+ LOGOUT(state) {
|
|
|
+ state.token = ''
|
|
|
+ state.roles = []
|
|
|
+ removeToken()
|
|
|
+ resetRouter()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -36,7 +43,7 @@ const actions = {
|
|
|
login({ username: username.trim(), password: password, type: type, captcha: captcha.trim() }).then(response => {
|
|
|
const { data } = response
|
|
|
commit('SET_TOKEN', data.token)
|
|
|
- setToken(data.token)
|
|
|
+ setToken(data.token,data.exp)
|
|
|
resolve(response)
|
|
|
}).catch(error => {
|
|
|
reject(error)
|
|
@@ -73,24 +80,24 @@ const actions = {
|
|
|
},
|
|
|
|
|
|
|
|
|
- logout({ commit, state, dispatch }) {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- logout(state.token).then(() => {
|
|
|
- commit('SET_TOKEN', '')
|
|
|
- commit('SET_ROLES', [])
|
|
|
- removeToken()
|
|
|
- resetRouter()
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- dispatch('tagsView/delAllViews', null, { root: true })
|
|
|
-
|
|
|
- resolve()
|
|
|
- }).catch(error => {
|
|
|
- reject(error)
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
resetToken({ commit }) {
|
|
@@ -102,7 +109,7 @@ const actions = {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
-
|
|
|
+
|
|
|
async changeRoles({ commit, dispatch }, role) {
|
|
|
const token = role + '-token'
|
|
|
|