diff --git a/src/layout/components/NavHeader/AccountDropdown.vue b/src/layout/components/NavHeader/AccountDropdown.vue index a69c81073..9f924d714 100644 --- a/src/layout/components/NavHeader/AccountDropdown.vue +++ b/src/layout/components/NavHeader/AccountDropdown.vue @@ -66,11 +66,15 @@ export default { break case 'logout': this.logout() - window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}` break } }, - logout() { + async logout() { + const currentOrg = this.$store.getters.currentOrg + if (currentOrg.autoEnter) { + await this.$store.dispatch('users/setCurrentOrg', this.$store.getters.preOrg) + } + window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}` } } } diff --git a/src/utils/startup.js b/src/utils/startup.js index 0f5de3aaa..a5e368a02 100644 --- a/src/utils/startup.js +++ b/src/utils/startup.js @@ -24,6 +24,9 @@ async function checkLogin({ to, from, next }) { } catch (e) { Vue.$log.error(e) const status = e.response.status + if (store.getters.currentOrg.autoEnter) { + await store.dispatch('users/setCurrentOrg', store.getters.preOrg) + } if (status === 401 || status === 403) { setTimeout(() => { window.location = process.env.VUE_APP_LOGIN_PATH