From f99bacbc3307cf313489106448db33f25a13eae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 4 Jun 2020 13:56:50 +0200 Subject: [PATCH] =?UTF-8?q?group=20des=20users=20wird=20st=C3=A4ndig=20akt?= =?UTF-8?q?ualisiert,=20sodass=20beim=20welchsel=20des=20barrechts=20nicht?= =?UTF-8?q?=20neu=20eingeloggt=20werden=20muss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/barUsers.js | 42 +++++++++++++++++++++++++++-------- src/store/modules/login.js | 6 +++++ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index 7717847..e82b2b9 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -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,12 +195,15 @@ 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 }) } catch { - //error + // error } }, async getAllUsers({ commit, rootState, dispatch }) { @@ -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) { diff --git a/src/store/modules/login.js b/src/store/modules/login.js index 5501fd4..f199244 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -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 })