From c206ab5b4a38f99bec4ee34d7b01bbabc83fa120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Wed, 19 Jun 2024 14:29:44 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E7=99=BB=E5=BD=95=E4=B8=8D=E5=90=8C=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E9=87=87=E7=94=A8=E6=96=B0=E6=96=B9?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/social/auth.ts | 8 ++++++-- src/layout/components/SocialCallback/index.vue | 6 ++++-- src/views/login.vue | 4 ++-- src/views/system/user/profile/thirdParty.vue | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/api/system/social/auth.ts b/src/api/system/social/auth.ts index 17a46d3..69f0d7e 100644 --- a/src/api/system/social/auth.ts +++ b/src/api/system/social/auth.ts @@ -1,10 +1,14 @@ import request from '@/utils/request'; // 绑定账号 -export function authBinding(source: string) { +export function authBinding(source: string, tenantId: string) { return request({ url: '/auth/binding/' + source, - method: 'get' + method: 'get', + params: { + tenantId: tenantId, + domain: window.location.host + } }); } diff --git a/src/layout/components/SocialCallback/index.vue b/src/layout/components/SocialCallback/index.vue index 7edae44..1cfeca8 100644 --- a/src/layout/components/SocialCallback/index.vue +++ b/src/layout/components/SocialCallback/index.vue @@ -17,8 +17,9 @@ const loading = ref(true); const code = route.query.code as string; const state = route.query.state as string; const source = route.query.source as string; -const tenantId = route.query.tenantId as string ? route.query.tenantId as string : '000000'; -const domain = route.query.domain as string; +const stateJson = JSON.parse(atob(state)); +const tenantId = stateJson.tenantId as string ? stateJson.tenantId as string : '000000'; +const domain = stateJson.domain as string; const processResponse = async (res: any) => { if (res.code !== 200) { @@ -67,6 +68,7 @@ const init = async () => { let urlFull = new URL(window.location.href); urlFull.host = domain; window.location.href = urlFull.toString(); + return; } const data: LoginData = { diff --git a/src/views/login.vue b/src/views/login.vue index 02c7d77..ca2903f 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -191,10 +191,10 @@ const initTenantList = async () => { * @param type */ const doSocialLogin = (type: string) => { - authBinding(type).then((res: any) => { + authBinding(type, loginForm.value.tenantId).then((res: any) => { if (res.code === HttpStatus.SUCCESS) { // 获取授权地址跳转 - window.location.href = res.data + '&tenantId=' + loginForm.value.tenantId + '&domain=' + window.location.host; + window.location.href = res.data; } else { ElMessage.error(res.msg); } diff --git a/src/views/system/user/profile/thirdParty.vue b/src/views/system/user/profile/thirdParty.vue index ad090c4..957122a 100644 --- a/src/views/system/user/profile/thirdParty.vue +++ b/src/views/system/user/profile/thirdParty.vue @@ -84,9 +84,9 @@ const unlockAuth = (row: any) => { }; const authUrl = (source: string) => { - authBinding(source).then((res: any) => { + authBinding(source, useUserStore().tenantId).then((res: any) => { if (res.code === 200) { - window.location.href = res.data + '&tenantId=' + useUserStore().tenantId + '&domain=' + window.location.host; + window.location.href = res.data; } else { proxy?.$modal.msgError(res.msg); }