fix: user login always change to system org

This commit is contained in:
Bai
2024-12-10 19:08:43 +08:00
committed by ZhaoJiSen
parent 367db0daf1
commit a87d04fb9d
4 changed files with 12 additions and 7 deletions

View File

@@ -71,7 +71,7 @@ export default {
},
async logout() {
const currentOrg = this.$store.getters.currentOrg
if (currentOrg.autoEnter) {
if (currentOrg.autoEnter || currentOrg.is_system) {
await this.$store.dispatch('users/setCurrentOrg', this.$store.getters.preOrg)
}
window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}`

View File

@@ -71,10 +71,11 @@ const mutations = {
state.consoleOrgs = state.consoleOrgs.filter(i => i.id !== org.id)
},
SET_CURRENT_ORG(state, org) {
// 系统组织和全局组织不设置成 Pre org
if (!state.currentOrg?.autoEnter) {
state.preOrg = state.currentOrg
setPreOrgLocal(state.username, state.currentOrg)
// 系统组织不设置成 Pre org
const currentOrg = state.currentOrg
if (!currentOrg?.autoEnter && !currentOrg.is_system) {
state.preOrg = currentOrg
setPreOrgLocal(state.username, currentOrg)
}
state.currentOrg = org
saveCurrentOrgLocal(state.username, org)
@@ -144,6 +145,7 @@ const actions = {
const systemOrg = {
id: orgUtil.SYSTEM_ORG_ID,
name: 'SystemSetting',
is_system: true,
autoEnter: new Date().getTime()
}
commit('SET_CURRENT_ORG', systemOrg)

View File

@@ -17,7 +17,7 @@ function getPropOrg() {
if (defaultOrg) {
return defaultOrg
}
return orgs.filter(item => !item['is_root'] && item.id !== SYSTEM_ORG_ID)[0]
return orgs.filter(item => !item['is_root'] && !item['is_system'])[0]
}
async function change2PropOrg() {

View File

@@ -8,7 +8,10 @@ import orgs from '@/api/orgs'
import { getPropView, isViewHasOrgs } from '@/utils/jms'
const whiteList = ['/login', process.env.VUE_APP_LOGIN_PATH] // no redirect whitelist
const autoEnterOrgs = ['00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000000']
const autoEnterOrgs = [
'00000000-0000-0000-0000-000000000001',
'00000000-0000-0000-0000-000000000000'
]
function reject(msg) {
return new Promise((resolve, reject) => reject(msg))