Skip to content

Commit

Permalink
reset user and dynamic nav items on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
elizavetaRa committed Apr 21, 2022
1 parent 42aca32 commit bbd3abd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-resetting-store-on-logout
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Resetting store on logout

When logging out, only some parts of vuex store were reset to default. This caused bugs by switching to another account that has some other/missing settings. For example, if the account has no quota, the quota of the previously logged in account was shown. We have fixed this by resetting the user store module on logout with reset function (vuex extensions library) and creating an action to reset dynamic nav items.

https://github.com/owncloud/web/pull/6694
https://github.com/owncloud/web/issues/6549
7 changes: 7 additions & 0 deletions packages/web-runtime/src/store/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const mutations = {
}
state.dynamicNavItems = dynamicNavItems
},
/* Sets dynamic nav items */
SET_DYNAMIC_NAV_ITEMS(state, navItems) {
state.dynamicNavItems = navItems
},
SET_CLOSED(state, closed) {
state.closed = closed
}
Expand Down Expand Up @@ -89,6 +93,9 @@ const actions = {
},
closeNavigation({ commit }) {
commit('SET_CLOSED', true)
},
clearDynamicNavItems({ commit }) {
commit('SET_DYNAMIC_NAV_ITEMS', {})
}
}
export default {
Expand Down
14 changes: 5 additions & 9 deletions packages/web-runtime/src/store/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ const actions = {
if (context.state.id === '') {
return
}
// reset user to default state
context.commit('SET_USER', state)
// reset capabilities to default state
context.commit('SET_CAPABILITIES', { capabilities: null, version: null })
// set userReady to false
context.commit('SET_USER_READY', false)
// reset user
this.reset({ self: false, nested: false, modules: { user: { self: true } } })

// clear dynamic navItems
context.dispatch('clearDynamicNavItems')

// clear oidc client state
vueAuthInstance.clearLoginState()
Expand All @@ -42,9 +41,6 @@ const actions = {
dispatch('hideModal')
dispatch('loadSettingsValues')

// Reset store
this.reset()

// Force redirect to login
if (forceRedirect) {
router.push({ name: 'login' })
Expand Down

0 comments on commit bbd3abd

Please sign in to comment.