兰宝车间质量管理系统-前端
疯狂的狮子Li
2024-06-19 c206ab5b4a38f99bec4ee34d7b01bbabc83fa120
update 优化 三方登录不同域名问题 采用新方案
已修改4个文件
22 ■■■■■ 文件已修改
src/api/system/social/auth.ts 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/components/SocialCallback/index.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/user/profile/thirdParty.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
    }
  });
}
src/layout/components/SocialCallback/index.vue
@@ -17,8 +17,9 @@
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 @@
    let urlFull = new URL(window.location.href);
    urlFull.host = domain;
    window.location.href = urlFull.toString();
    return;
  }
  const data: LoginData = {
src/views/login.vue
@@ -191,10 +191,10 @@
 * @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);
    }
src/views/system/user/profile/thirdParty.vue
@@ -84,9 +84,9 @@
};
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);
    }