group des users wird ständig aktualisiert, sodass beim welchsel des barrechts nicht neu eingeloggt werden muss

This commit is contained in:
Tim Gröger 2020-06-04 13:56:50 +02:00
parent 3d9ab23a20
commit f99bacbc33
2 changed files with 39 additions and 9 deletions

View File

@ -135,7 +135,10 @@ const actions = {
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
location.reload()
}
}
commit('setUsersLoading', false)
},
@ -165,7 +168,10 @@ const actions = {
error: true
})
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
location.reload()
}
}
try {
commit('updateUser', { username: data.username, loading: false })
@ -189,7 +195,10 @@ const actions = {
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
location.reload()
}
}
try {
commit('updateUser', { username: data.username, loading: false })
@ -207,7 +216,10 @@ const actions = {
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
if (e.response.data === 401) {
dispatch('getLifeTime', null, { root: true })
location.reload()
}
}
commit('setAllUsersLoading', false)
},
@ -227,7 +239,10 @@ const actions = {
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
location.reload()
}
}
commit('updateMessage', { date: data.date, loading: false })
},
@ -240,7 +255,10 @@ const actions = {
commit('setLocked', response.data.value)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
location.reload()
}
}
},
async setLocked({ commit, rootState, dispatch }) {
@ -253,7 +271,10 @@ const actions = {
commit('setLocked', response.data.value)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
location.reload()
}
}
},
async unlock({ commit, rootState, dispatch }, password) {
@ -273,7 +294,10 @@ const actions = {
}
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
location.reload()
}
}
},
setFilter({ commit }, data) {

View File

@ -156,6 +156,12 @@ const actions = {
headers: { Token: rootState.login.user.accessToken }
})
commit('setLifeTime', response.data.value)
var user = JSON.parse(localStorage.getItem('user'))
console.log('user',user)
user.group = response.data.group
console.log('after',user)
localStorage.setItem('user', JSON.stringify(user))
commit('updateAccessToken', user)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })