forked from github/dataease
Merge pull request #9079 from dataease/pr@dev@feat_custom_logout_url
feat: 可自定义登出路径
This commit is contained in:
commit
281c66d45c
@ -159,12 +159,13 @@ const actions = {
|
|||||||
// user logout
|
// user logout
|
||||||
logout({ commit, state }, param) {
|
logout({ commit, state }, param) {
|
||||||
const method = param && param.casEnable ? deLogout : logout
|
const method = param && param.casEnable ? deLogout : logout
|
||||||
|
const customLogoutUrl = localStorage.getItem('custom_auth_logout_url')
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
method(state.token).then(res => {
|
method(state.token).then(res => {
|
||||||
removeToken() // must remove token first
|
removeToken() // must remove token first
|
||||||
resetRouter()
|
resetRouter()
|
||||||
commit('RESET_STATE')
|
commit('RESET_STATE')
|
||||||
resolve(res.data)
|
resolve(customLogoutUrl || res.data)
|
||||||
localStorage.removeItem('passwordModified')
|
localStorage.removeItem('passwordModified')
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
@ -179,8 +180,7 @@ const actions = {
|
|||||||
}, {
|
}, {
|
||||||
confirmButtonText: i18n.t('commons.confirm')
|
confirmButtonText: i18n.t('commons.confirm')
|
||||||
})
|
})
|
||||||
}
|
} else if (error.response.data.message === ('cas_logout_error')) {
|
||||||
if (error.response.data.message === ('cas_logout_error')) {
|
|
||||||
const message = i18n.t('logout.' + error.response.data.message)
|
const message = i18n.t('logout.' + error.response.data.message)
|
||||||
$alert(message, () => {
|
$alert(message, () => {
|
||||||
|
|
||||||
@ -188,7 +188,11 @@ const actions = {
|
|||||||
confirmButtonText: i18n.t('commons.confirm'),
|
confirmButtonText: i18n.t('commons.confirm'),
|
||||||
showClose: false
|
showClose: false
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
window.location.href = customLogoutUrl || '/'
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
window.location.href = customLogoutUrl || '/'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user