mirror of https://github.com/veops/cmdb.git
Merge pull request #48 from lovvvve/master
fix(sso login): sso login redirect
This commit is contained in:
commit
ab70b2a655
|
@ -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,
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
|
||||
export default {
|
||||
showLocale: true,
|
||||
defaultLang: 'en-US', // zh-CN | en-US
|
||||
defaultLang: 'zh-CN', // zh-CN | en-US
|
||||
useSSO: false,
|
||||
ssoLogoutRedirectUrl: 'https://xxx.yyy.com/zzz/logout',
|
||||
ssoLoginRedirectUrl: 'https://xxx.yyy.com/zzz/login',
|
||||
primaryColor: '#1890ff', // primary color of ant design
|
||||
navTheme: 'dark', // theme for nav menu
|
||||
layout: 'sidemenu', // nav menu position: sidemenu or topmenu
|
||||
|
|
|
@ -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