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