mirror of https://github.com/veops/cmdb.git
fix(sso login): sso login redirect
This commit is contained in:
parent
0da1712343
commit
a44be48c7e
|
@ -1,8 +1,8 @@
|
||||||
import config from '@/config/defaultSettings'
|
import config from '@/config/defaultSettings'
|
||||||
|
|
||||||
const api = {
|
const api = {
|
||||||
Login: config.useSSO ? '/api/sso/login' : '/login',
|
Login: config.useSSO ? config.ssoLoginRedirectUrl : '/login',
|
||||||
Logout: config.useSSO ? '/api/sso/logout' : '/logout',
|
Logout: config.useSSO ? config.ssoLogoutRedirectUrl : '/logout',
|
||||||
ForgePassword: '/auth/forge-password',
|
ForgePassword: '/auth/forge-password',
|
||||||
Register: '/auth/register',
|
Register: '/auth/register',
|
||||||
twoStepCode: '/auth/2step-code',
|
twoStepCode: '/auth/2step-code',
|
||||||
|
|
|
@ -39,9 +39,10 @@ export function getInfo () {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logout () {
|
export function logout () {
|
||||||
console.log('logout........')
|
console.log('logout........', config.useSSO)
|
||||||
if (config.useSSO) {
|
if (config.useSSO) {
|
||||||
window.location.replace(api.Logout)
|
window.location.href = api.Logout
|
||||||
|
return Promise.resolve()
|
||||||
} else {
|
} else {
|
||||||
return axios({
|
return axios({
|
||||||
url: api.Logout,
|
url: api.Logout,
|
||||||
|
|
|
@ -42,13 +42,13 @@ router.beforeEach((to, from, next) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.log(e)
|
|
||||||
notification.error({
|
notification.error({
|
||||||
message: this.$t('tip.error'),
|
message: e.message,
|
||||||
description: 'Failed to request user information. Please try again!'
|
description: 'Failed to request user information. Please try again!'
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
store.dispatch('Logout')
|
console.log('should re-login')
|
||||||
|
store.dispatch('Login')
|
||||||
}, 3000)
|
}, 3000)
|
||||||
})
|
})
|
||||||
} else if (to.path === '/user/login' && !config.useSSO && store.getters.roles.length !== 0) {
|
} else if (to.path === '/user/login' && !config.useSSO && store.getters.roles.length !== 0) {
|
||||||
|
|
|
@ -75,18 +75,10 @@ const user = {
|
||||||
|
|
||||||
// logout
|
// logout
|
||||||
Logout ({ commit, state }) {
|
Logout ({ commit, state }) {
|
||||||
return new Promise((resolve) => {
|
|
||||||
commit('SET_TOKEN', '')
|
commit('SET_TOKEN', '')
|
||||||
commit('SET_ROLES', [])
|
commit('SET_ROLES', [])
|
||||||
Vue.ls.remove(ACCESS_TOKEN)
|
Vue.ls.remove(ACCESS_TOKEN)
|
||||||
|
return logout(state.token)
|
||||||
logout(state.token).then(() => {
|
|
||||||
window.location.reload()
|
|
||||||
resolve()
|
|
||||||
}).catch(() => {
|
|
||||||
resolve()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue