【新增】新增sso
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { instance as request } from '@/utils/request'
|
||||
|
||||
export default {
|
||||
// 登录
|
||||
ssoLogin(data) {
|
||||
return request({
|
||||
url: '/api/ssoLogin',
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
},
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
const isDev = process.env.NODE_ENV && process.env.NODE_ENV === 'development'
|
||||
console.log(isDev,"process.env.")
|
||||
let myUrl=encodeURI('http://10.0.1.14:8080/checkPage')
|
||||
const routes = [
|
||||
{
|
||||
path: '/system',
|
||||
@@ -15,16 +18,33 @@ const routes = [
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
redirect: {
|
||||
name: 'Login'
|
||||
// path: '/report/list?id=XBFBR7UADZ'
|
||||
}
|
||||
redirect: () => {
|
||||
window.location.href ='https://iamuat.faw-vw.com/esc-sso/oauth2.0/authorize/old?isADSSO=true&response_type=code&client_id=&redirect_uri='+myUrl
|
||||
}
|
||||
// window.location.href = "https://sso-qa.saicmotortest.com/idp/oauth2/authorize?redirect_uri=https://www.baidu.com/&state=gsrm&client_id=GSRM&response_type=code"
|
||||
|
||||
},
|
||||
{
|
||||
path: '/checkPage',
|
||||
component: () => import('../../views/checkPage.vue')
|
||||
|
||||
},
|
||||
// 登录
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
redirect: () => {
|
||||
window.location.href ='https://iamuat.faw-vw.com/esc-sso/oauth2.0/authorize/old?isADSSO=true&response_type=code&client_id=&redirect_uri='+myUrl
|
||||
// window.location.href = "https://sso-qa.saicmotortest.com/idp/oauth2/authorize?redirect_uri=https://www.baidu.com/&state=gsrm&client_id=GSRM&response_type=code"
|
||||
}
|
||||
// window.location.href = "https://sso-qa.saicmotortest.com/idp/oauth2/authorize?redirect_uri=https://www.baidu.com/&state=gsrm&client_id=GSRM&response_type=code"
|
||||
},
|
||||
// 登录
|
||||
{
|
||||
path: '/loginout',
|
||||
name: 'Login',
|
||||
component: () => import('../../views/Login.vue')
|
||||
// window.location.href = "https://sso-qa.saicmotortest.com/idp/oauth2/authorize?redirect_uri=https://www.baidu.com/&state=gsrm&client_id=GSRM&response_type=code"
|
||||
},
|
||||
// // 注册
|
||||
// {
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<!--sso单点登录-->
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "checkPage",
|
||||
data(){
|
||||
return {
|
||||
code:''
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
getLogin(){
|
||||
this.$api.sso.ssoLogin({code:this.code}).then(res=>{
|
||||
res.data.roleIdList=res.data.roleEOList.map(item=>{
|
||||
return item.id
|
||||
})
|
||||
|
||||
this.$store.commit('saveUserInfo', res.data)
|
||||
this.$api.menu.getSysMenu({ roleId: this.$store.getters.userInfo.roleIdList[0] }).then(({ data }) => {
|
||||
if (data === null) {
|
||||
data = []
|
||||
}
|
||||
data = data.sort((a, b) => a.sort - b.sort)
|
||||
const menu = data.filter(item => item.belong && (item.isButton=='0'|| !item.isButton))
|
||||
if(menu.length==0){
|
||||
this.$api.login.logout().then(_ => {
|
||||
this.$message.warning('暂无权限,请联系管理员授权')
|
||||
this.$store.commit('saveUserInfo', null)
|
||||
this.$store.commit('setHandleProcess', null)
|
||||
this.$store.commit('savePathUrl', null)
|
||||
this.$store.commit('removeDicts', null)
|
||||
// var sevice = "http://"+window.location.host+"/";
|
||||
// var serviceUrl = encodeURIComponent(sevice);
|
||||
// 正式
|
||||
// window.open("https://caddmuat.changan.com.cn/cas/logout?service=http://10.64.23.30:7766/home", '_self');
|
||||
// 测试
|
||||
// window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self');
|
||||
this.$router.push('/login')
|
||||
})
|
||||
return
|
||||
}else{
|
||||
let routeList=menu.map(item=> item.href)
|
||||
let params
|
||||
if(routeList.indexOf('/report/list')>-1){
|
||||
params={ path: '/report/list', query: { id: 'AEHJB8YNJ3' }}
|
||||
}else if(routeList.indexOf('/report/manager')>-1){
|
||||
params={ path: '/report/manager', query: { id: 'AEHJB8YNJ3' }}
|
||||
}else if(routeList.indexOf('/userCenter/processCenter')>-1){
|
||||
params={ path: '/userCenter/processCenter', query: { id: 'AEHJB8YNJ3' }}
|
||||
}
|
||||
this.$message.success('登录成功')
|
||||
this.getMarket().then((resx)=>{
|
||||
this.$store.commit('setMarketpre', resx)
|
||||
this.$router.push(params)
|
||||
}).catch((resx)=>{
|
||||
this.$store.commit('setMarketpre', '')
|
||||
this.$router.push({ path: '/report/list', query: { id: 'AEHJB8YNJ3' } })
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
this.code=this.$route.query.code || ''
|
||||
// isADSSO=true&client_id=XXXX&response_type=code&redirect_uri=http%3A%2F%2FXXX.XXXX.XXXX.XXX%3A8080%2FXXXX%2FXXXX&state=http%3A%2F%2Fwww.app1.com%2Ftodu%2F1w2341123
|
||||
if(this.code==''){
|
||||
let myUrl=encodeURI('http://10.0.1.14:8080/checkPage')
|
||||
window.open('https://iamuat.faw-vw.com/esc-sso/oauth2.0/authorize/old?isADSSO=true&response_type=code&client_id=&redirect_uri='+myUrl)
|
||||
}else{
|
||||
this.getLogin()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user