From 651169b48b3ab8664eec68e3b263f283bf8c1204 Mon Sep 17 00:00:00 2001 From: Zhao Zhao Shen Date: Mon, 18 Nov 2024 14:46:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Doneid=E7=99=BB?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=E7=99=BB=E5=BD=95=E5=A4=B1=E8=B4=A5=EF=BC=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=BF=9B=E5=85=A5=E6=89=8B=E5=8A=A8=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.js | 1 + src/views/callback/index.vue | 19 ++++++++++++------- vue.config.js | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/permission.js b/src/permission.js index 6edb396..5a2259b 100644 --- a/src/permission.js +++ b/src/permission.js @@ -74,6 +74,7 @@ router.beforeEach(async(to, from, next) => { } else { window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://localhost:9528/callback&scope=openid%20phone' + // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=https://cs-vsc.siemens.com.cn:444/callback&scope=openid%20phone' } NProgress.done() } diff --git a/src/views/callback/index.vue b/src/views/callback/index.vue index f58a962..e32ce07 100644 --- a/src/views/callback/index.vue +++ b/src/views/callback/index.vue @@ -26,13 +26,18 @@ export default { // 发送 code 给后端进行验证和处理 const response = await getOneIdToken(code) if (response) { - console.log('response.Token:' + response.data.token) - // 存token - this.$store.dispatch('user/commitToken', response.data.token) - // 重新加载路由 这里不对 - // resetRouter() 这个没用,还把你的路由破坏了 - // console.log(this.$store.state.user, this.$store.state.token) - this.$router.push({ path: '/nav' }) + console.log('🐱one自动登录接口状态:', response.code) + if (response.code === 200) { + console.log('response.Token:' + response.data.token) + // 存token + this.$store.dispatch('user/commitToken', response.data.token) + // 重新加载路由 这里不对 + // resetRouter() 这个没用,还把你的路由破坏了 + // console.log(this.$store.state.user, this.$store.state.token) + this.$router.push({ path: '/nav' }) + } else { + this.$router.push({ path: '/login' }) + } } else { console.log('No token found with code') window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' diff --git a/vue.config.js b/vue.config.js index 34c7fb4..4519719 100644 --- a/vue.config.js +++ b/vue.config.js @@ -40,7 +40,7 @@ module.exports = { [process.env.VUE_APP_BASE_API]: { target: 'http://139.219.4.195:8003', // 测试地址 - // target: 'http://192.168.1.169:8003', + // target: 'http://192.168.237.154:8003', pathRewrite: { ['^' + process.env.VUE_APP_BASE_API]: '' }