|
1 | 1 | <template> |
2 | | - <!-- <div v-if="loginCategory.qrcode" :class="{ 'de-qr-hidden': !qrStatus }"> |
| 2 | + <div v-if="loginCategory.qrcode" :class="{ 'de-qr-hidden': !qrStatus }"> |
3 | 3 | <QrTab |
4 | 4 | v-if="qrStatus" |
5 | 5 | :wecom="loginCategory.wecom" |
6 | 6 | :dingtalk="loginCategory.dingtalk" |
7 | 7 | :lark="loginCategory.lark" |
8 | 8 | :larksuite="loginCategory.larksuite" |
9 | 9 | /> |
10 | | - </div> --> |
| 10 | + </div> |
11 | 11 | <LdapLoginForm v-if="isLdap" /> |
12 | 12 | <el-divider v-if="anyEnable" class="de-other-login-divider">{{ |
13 | 13 | t('login.other_login') |
|
54 | 54 | import { ref, onMounted, nextTick, computed } from 'vue' |
55 | 55 | import QrcodeLdap from './QrcodeLdap.vue' |
56 | 56 | import LdapLoginForm from './LdapLoginForm.vue' |
57 | | -/* import Oidc from './Oidc.vue' |
58 | | -import Oauth2 from './Oauth2.vue' |
59 | | -import Saml2 from './Saml2.vue' */ |
| 57 | +
|
60 | 58 | import Oidc from './Oidc.vue' |
61 | 59 | import Cas from './Cas.vue' |
62 | 60 | import Oauth2 from './Oauth2.vue' |
63 | | -// import QrTab from './QrTab.vue' |
| 61 | +import QrTab from './QrTab.vue' |
64 | 62 | import { request } from '@/utils/request' |
65 | 63 | import { useCache } from '@/utils/useCache' |
66 | 64 |
|
@@ -197,6 +195,8 @@ const init = (cb?: () => void) => { |
197 | 195 | .then((res) => { |
198 | 196 | if (res) { |
199 | 197 | const list: any[] = res as any[] |
| 198 | + /* list.push({ name: 'qrcode', enable: true }) |
| 199 | + list.push({ name: 'wecom', enable: true }) */ |
200 | 200 | list.forEach((item: { name: keyof LoginCategory; enable: boolean }) => { |
201 | 201 | loginCategory.value[item.name] = item.enable |
202 | 202 | if (item.enable) { |
@@ -416,6 +416,72 @@ const oidcLogin = () => { |
416 | 416 | }, 1500) |
417 | 417 | }) |
418 | 418 | } |
| 419 | +const wecomLogin = () => { |
| 420 | + const urlParams = getUrlParams() |
| 421 | + request |
| 422 | + .post('/system/platform/sso/6', urlParams) |
| 423 | + .then((res: any) => { |
| 424 | + const token = res.access_token |
| 425 | + // const platform_info = res.platform_info |
| 426 | + if (token && isPlatformClient()) { |
| 427 | + wsCache.set('de-platform-client', true) |
| 428 | + } |
| 429 | + userStore.setToken(token) |
| 430 | + userStore.setExp(res.exp) |
| 431 | + userStore.setTime(Date.now()) |
| 432 | + userStore.setPlatformInfo({ |
| 433 | + flag: 'wecom', |
| 434 | + // data: platform_info ? JSON.stringify(platform_info) : '', |
| 435 | + origin: 6, |
| 436 | + }) |
| 437 | + const queryRedirectPath = getCurLocation() |
| 438 | + router.push({ path: queryRedirectPath }) |
| 439 | + }) |
| 440 | + .catch((e: any) => { |
| 441 | + userStore.setToken('') |
| 442 | + setTimeout(() => { |
| 443 | + // logoutHandler(true, true) |
| 444 | + platformLoginMsg.value = e?.message || e |
| 445 | + setTimeout(() => { |
| 446 | + window.location.href = |
| 447 | + window.location.origin + window.location.pathname + window.location.hash |
| 448 | + }, 2000) |
| 449 | + }, 1500) |
| 450 | + }) |
| 451 | +} |
| 452 | +const dingtalkLogin = () => { |
| 453 | + const urlParams = getUrlParams() |
| 454 | + request |
| 455 | + .post('/system/platform/sso/7', urlParams) |
| 456 | + .then((res: any) => { |
| 457 | + const token = res.access_token |
| 458 | + // const platform_info = res.platform_info |
| 459 | + if (token && isPlatformClient()) { |
| 460 | + wsCache.set('de-platform-client', true) |
| 461 | + } |
| 462 | + userStore.setToken(token) |
| 463 | + userStore.setExp(res.exp) |
| 464 | + userStore.setTime(Date.now()) |
| 465 | + userStore.setPlatformInfo({ |
| 466 | + flag: 'dingtalk', |
| 467 | + // data: platform_info ? JSON.stringify(platform_info) : '', |
| 468 | + origin: 7, |
| 469 | + }) |
| 470 | + const queryRedirectPath = getCurLocation() |
| 471 | + router.push({ path: queryRedirectPath }) |
| 472 | + }) |
| 473 | + .catch((e: any) => { |
| 474 | + userStore.setToken('') |
| 475 | + setTimeout(() => { |
| 476 | + // logoutHandler(true, true) |
| 477 | + platformLoginMsg.value = e?.message || e |
| 478 | + setTimeout(() => { |
| 479 | + window.location.href = |
| 480 | + window.location.origin + window.location.pathname + window.location.hash |
| 481 | + }, 2000) |
| 482 | + }, 1500) |
| 483 | + }) |
| 484 | +} |
419 | 485 | /* const platformLogin = (origin: number) => { |
420 | 486 | const url = '/system/authentication/sso/cas' |
421 | 487 | request |
@@ -591,6 +657,10 @@ onMounted(() => { |
591 | 657 | oauth2Login() |
592 | 658 | } else if (state?.includes('oidc')) { |
593 | 659 | oidcLogin() |
| 660 | + } else if (state?.includes('wecom')) { |
| 661 | + wecomLogin() |
| 662 | + } else if (state?.includes('dingtalk')) { |
| 663 | + dingtalkLogin() |
594 | 664 | } else { |
595 | 665 | auto2Platform() |
596 | 666 | } |
|
0 commit comments