@authing/react-ui-components 3.0.2-beta.5 → 3.1.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +1 -1
- package/LICENSE +21 -0
- package/config/env.js +26 -24
- package/config/paths.js +3 -3
- package/config/webpack.config.js +29 -7
- package/lib/index.d.ts +211 -1252
- package/lib/index.min.css +1 -2
- package/lib/index.min.js +1 -1
- package/lib/index.min.js.LICENSE.txt +0 -32
- package/package.json +14 -20
- package/scripts/build.js +83 -79
- package/scripts/start.js +73 -69
- package/scripts/test.js +23 -19
- package/{components → src/common}/AuthingDropdown/index.tsx +1 -1
- package/{components → src/common}/AuthingDropdown/style.less +0 -0
- package/{components → src/common}/AuthingTabs/index.tsx +1 -1
- package/{components → src/common}/AuthingTabs/style.less +0 -0
- package/{components → src/common}/CopyAbleText/index.tsx +1 -1
- package/{components → src/common}/CopyAbleText/style.less +0 -0
- package/{components → src/common}/VerifyCodeInput/index.tsx +0 -0
- package/{components → src/common}/VerifyCodeInput/style.less +0 -0
- package/{components → src/components}/AuthingGuard/AppMFALayout/index.tsx +2 -2
- package/{components → src/components}/AuthingGuard/AppMFALayout/style.less +0 -0
- package/{components → src/components}/AuthingGuard/CompleteUserInfoLayout/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/CompleteUserInfoLayout/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/ADLoginForm/index.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/Agreements/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/Agreements/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +3 -3
- package/{components → src/components}/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +4 -2
- package/{components → src/components}/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/EmailRegisterForm/index.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/LdapLoginForm/index.tsx +4 -9
- package/{components → src/components}/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/LoginFormFooter/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/LoginFormFooter/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/MfaVerifyForm/index.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/PasswordLoginForm/index.tsx +3 -3
- package/{components → src/components}/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +4 -2
- package/{components → src/components}/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/RegisterFormFooter/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -0
- package/{components → src/components}/AuthingGuard/Forms/SendPhoneCode/index.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/SendPhoneCode/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +2 -2
- package/{components → src/components}/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +7 -7
- package/{components → src/components}/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Forms/UploadImage/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/Forms/index.ts +0 -0
- package/{components → src/components}/AuthingGuard/GuardLayout/index.tsx +17 -3
- package/{components → src/components}/AuthingGuard/GuardLayout/style.less +0 -0
- package/{components → src/components}/AuthingGuard/Header/index.tsx +6 -3
- package/{components → src/components}/AuthingGuard/Header/style.less +23 -11
- package/{components → src/components}/AuthingGuard/IconFont/iconfont.js +0 -0
- package/{components → src/components}/AuthingGuard/IconFont/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/IconFont/style.less +0 -0
- package/{components → src/components}/AuthingGuard/IconFont/svg.js +0 -0
- package/{components → src/components}/AuthingGuard/LoginLayout/index.tsx +69 -25
- package/{components → src/components}/AuthingGuard/LoginLayout/style.less +0 -0
- package/{components → src/components}/AuthingGuard/MfaLayout/Steps.ts +0 -0
- package/{components → src/components}/AuthingGuard/MfaLayout/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/MfaLayout/style.less +0 -0
- package/{components → src/components}/AuthingGuard/RegisterLayout/index.tsx +2 -2
- package/{components → src/components}/AuthingGuard/RegisterLayout/style.less +0 -0
- package/{components → src/components}/AuthingGuard/ResetPwdLayout/index.tsx +1 -1
- package/{components → src/components}/AuthingGuard/ToggleLang/index.tsx +2 -2
- package/{components → src/components}/AuthingGuard/api/appConfig.ts +22 -14
- package/{components/_utils → src/components/AuthingGuard/api}/http.ts +33 -30
- package/{components → src/components}/AuthingGuard/api/index.ts +0 -0
- package/{components → src/components}/AuthingGuard/api/sso.ts +1 -1
- package/{components → src/components}/AuthingGuard/api/userPoolConfig.ts +3 -2
- package/{components → src/components}/AuthingGuard/constants.ts +2 -2
- package/{components → src/components}/AuthingGuard/hooks/index.tsx +0 -0
- package/{components → src/components}/AuthingGuard/hooks/useScreenSize.tsx +0 -0
- package/{components → src/components}/AuthingGuard/index.tsx +11 -3
- package/{components/_utils → src/components/AuthingGuard}/locales/en/common.json +26 -70
- package/{components/_utils → src/components/AuthingGuard}/locales/en/index.ts +0 -0
- package/{components/_utils → src/components/AuthingGuard}/locales/en/login.json +19 -21
- package/{components/_utils → src/components/AuthingGuard}/locales/en/map.json +0 -0
- package/{components/_utils → src/components/AuthingGuard}/locales/en/user.json +3 -4
- package/{components/_utils → src/components/AuthingGuard}/locales/index.ts +2 -2
- package/{components/_utils → src/components/AuthingGuard}/locales/zh/common.json +9 -53
- package/{components/_utils → src/components/AuthingGuard}/locales/zh/index.ts +0 -0
- package/{components/_utils → src/components/AuthingGuard}/locales/zh/login.json +4 -6
- package/{components/_utils → src/components/AuthingGuard}/locales/zh/map.json +0 -0
- package/{components/_utils → src/components/AuthingGuard}/locales/zh/user.json +1 -3
- package/{components → src/components}/AuthingGuard/style.less +5 -0
- package/{components → src/components}/AuthingGuard/types/Forms.ts +2 -1
- package/{components → src/components}/AuthingGuard/types/GuardConfig.ts +5 -1
- package/{components → src/components}/AuthingGuard/types/GuardState.ts +1 -1
- package/{components → src/components}/AuthingGuard/types/Locales.ts +0 -0
- package/{components → src/components}/AuthingGuard/types/index.ts +0 -0
- package/src/components/index.ts +7 -0
- package/{components → src}/context/base.tsx +0 -0
- package/{components → src}/context/global/context.tsx +0 -0
- package/{components → src}/context/global/reducer.tsx +2 -2
- package/src/index.tsx +142 -0
- package/{logo.svg → src/logo.svg} +0 -0
- package/{react-app-env.d.ts → src/react-app-env.d.ts} +0 -0
- package/{reportWebVitals.ts → src/reportWebVitals.ts} +0 -0
- package/{setupTests.ts → src/setupTests.ts} +0 -0
- package/{components/_utils → src/utils}/clipboard.ts +1 -1
- package/{components/_utils → src/utils}/index.ts +3 -149
- package/{components/_utils → src/utils}/popupCenter.ts +0 -0
- package/tsconfig.json +2 -8
- package/build/asset-manifest.json +0 -26
- package/build/favicon.ico +0 -0
- package/build/index.html +0 -1
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +0 -25
- package/build/robots.txt +0 -3
- package/build/static/css/2.51c07e65.chunk.css +0 -3
- package/build/static/css/2.51c07e65.chunk.css.map +0 -1
- package/build/static/css/main.779f221a.chunk.css +0 -2
- package/build/static/css/main.779f221a.chunk.css.map +0 -1
- package/build/static/js/2.bbae9fdb.chunk.js +0 -3
- package/build/static/js/2.bbae9fdb.chunk.js.LICENSE.txt +0 -102
- package/build/static/js/2.bbae9fdb.chunk.js.map +0 -1
- package/build/static/js/3.fd17f196.chunk.js +0 -2
- package/build/static/js/3.fd17f196.chunk.js.map +0 -1
- package/build/static/js/main.5f341531.chunk.js +0 -2
- package/build/static/js/main.5f341531.chunk.js.map +0 -1
- package/build/static/js/runtime-main.ef138021.js +0 -2
- package/build/static/js/runtime-main.ef138021.js.map +0 -1
- package/build/static/media/loading.4a67a5f3.svg +0 -29
- package/components/BindTotp/core/bindSuccess.tsx +0 -72
- package/components/BindTotp/core/securityCode.tsx +0 -108
- package/components/BindTotp/index.tsx +0 -134
- package/components/BindTotp/interface.ts +0 -30
- package/components/BindTotp/styles.less +0 -57
- package/components/ChangeLanguage/index.tsx +0 -35
- package/components/ChangePassword/core/firstLoginReset.tsx +0 -111
- package/components/ChangePassword/core/rotateReset.tsx +0 -114
- package/components/ChangePassword/index.tsx +0 -72
- package/components/CompleteInfo/core/completeInfo.tsx +0 -155
- package/components/CompleteInfo/index.tsx +0 -45
- package/components/CompleteInfo/interface.ts +0 -40
- package/components/CompleteInfo/styles.less +0 -7
- package/components/DownloadAuthenticator/index.tsx +0 -97
- package/components/DownloadAuthenticator/interface.ts +0 -22
- package/components/DownloadAuthenticator/styles.less +0 -52
- package/components/Error/index.tsx +0 -21
- package/components/Error/interface.ts +0 -9
- package/components/Error/styles.less +0 -12
- package/components/ForgetPassword/core/resetPassword.tsx +0 -162
- package/components/ForgetPassword/index.tsx +0 -78
- package/components/ForgetPassword/interface.ts +0 -32
- package/components/Guard/Guard.tsx +0 -295
- package/components/Guard/authClient.ts +0 -44
- package/components/Guard/config.ts +0 -19
- package/components/Guard/event.ts +0 -52
- package/components/Guard/index.tsx +0 -4
- package/components/Guard/module.ts +0 -20
- package/components/Guard/stateMachine.ts +0 -152
- package/components/Guard/styles.less +0 -461
- package/components/IconFont/iconfont.js +0 -74
- package/components/IconFont/index.tsx +0 -16
- package/components/IconFont/style.less +0 -6
- package/components/IconFont/svg.js +0 -2
- package/components/ImagePro/index.tsx +0 -53
- package/components/ImagePro/styles.less +0 -40
- package/components/InputNumber/index.tsx +0 -33
- package/components/Login/codemap.ts +0 -49
- package/components/Login/core/withAD.tsx +0 -9
- package/components/Login/core/withAppQrcode.tsx +0 -49
- package/components/Login/core/withLDAP.tsx +0 -146
- package/components/Login/core/withPassword/FormItemAccount.tsx +0 -42
- package/components/Login/core/withPassword/GraphicVerifyCode.tsx +0 -30
- package/components/Login/core/withPassword/InputAccount.tsx +0 -64
- package/components/Login/core/withPassword/index.tsx +0 -173
- package/components/Login/core/withPhonecode.tsx +0 -122
- package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
- package/components/Login/core/withWechatmpQrcode.tsx +0 -53
- package/components/Login/index.tsx +0 -374
- package/components/Login/props.ts +0 -74
- package/components/Login/socialLogin/index.tsx +0 -407
- package/components/Login/socialLogin/style.less +0 -69
- package/components/Login/styles.less +0 -53
- package/components/MFA/VerifyCodeInput/VerifyCodeFormItem.tsx +0 -41
- package/components/MFA/VerifyCodeInput/index.tsx +0 -145
- package/components/MFA/VerifyCodeInput/style.less +0 -35
- package/components/MFA/codemap.ts +0 -24
- package/components/MFA/core/email.tsx +0 -203
- package/components/MFA/core/face.tsx +0 -297
- package/components/MFA/core/face_deps.tsx +0 -37
- package/components/MFA/core/sms.tsx +0 -203
- package/components/MFA/core/totp.tsx +0 -122
- package/components/MFA/index.tsx +0 -143
- package/components/MFA/mfaMethods/index.tsx +0 -88
- package/components/MFA/mfaMethods/style.less +0 -39
- package/components/MFA/props.ts +0 -51
- package/components/MFA/styles.less +0 -100
- package/components/NeedHelpView/core/describeQuestions.tsx +0 -245
- package/components/NeedHelpView/index.tsx +0 -47
- package/components/RecoveryCode/core/useCode.tsx +0 -71
- package/components/RecoveryCode/index.tsx +0 -27
- package/components/RecoveryCode/interface.ts +0 -31
- package/components/RecoveryCode/style.less +0 -13
- package/components/Register/codemap.ts +0 -12
- package/components/Register/components/Agreements/index.tsx +0 -81
- package/components/Register/components/Agreements/style.less +0 -44
- package/components/Register/core/WithEmail.tsx +0 -242
- package/components/Register/core/WithPhone.tsx +0 -184
- package/components/Register/index.tsx +0 -139
- package/components/Register/props.ts +0 -50
- package/components/SendCode/SendCodeBtn.tsx +0 -96
- package/components/SendCode/index.tsx +0 -94
- package/components/SendCode/style.less +0 -31
- package/components/ShieldSpin/index.tsx +0 -27
- package/components/ShieldSpin/loading.svg +0 -29
- package/components/SubmitButton/index.tsx +0 -50
- package/components/SubmitSuccess/index.tsx +0 -66
- package/components/SubmitSuccess/interface.ts +0 -17
- package/components/Type/index.ts +0 -52
- package/components/ValidatorRules/ValidatorFormItem.tsx +0 -139
- package/components/ValidatorRules/index.ts +0 -20
- package/components/_utils/GuardErrorCode.ts +0 -9
- package/components/_utils/config.ts +0 -116
- package/components/_utils/guradHttp.ts +0 -101
- package/components/_utils/hooks/index.ts +0 -64
- package/components/assets/images/error.png +0 -0
- package/components/context/module/context.tsx +0 -23
- package/components/index.ts +0 -12
- package/examples.tsx +0 -87
- package/index.js +0 -1
- package/lib/static/media/loading.4a67a5f3.svg +0 -29
- package/scripts/publish.js +0 -57
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
3
|
-
import { message, Tabs } from 'antd'
|
|
4
|
-
import { intersection } from 'lodash'
|
|
5
|
-
|
|
6
|
-
import { LoginWithPassword } from './core/withPassword/index'
|
|
7
|
-
import { LoginWithPhoneCode } from './core/withPhonecode'
|
|
8
|
-
import { LoginWithLDAP } from './core/withLDAP'
|
|
9
|
-
import { LoginWithAD } from './core/withAD'
|
|
10
|
-
import { LoginWithAppQrcode } from './core/withAppQrcode'
|
|
11
|
-
import { LoginWithWechatMiniQrcode } from './core/withWechatMiniQrcode'
|
|
12
|
-
import { LoginWithWechatmpQrcode } from './core/withWechatmpQrcode'
|
|
13
|
-
import { codeMap } from './codemap'
|
|
14
|
-
import { SocialLogin } from './socialLogin'
|
|
15
|
-
import { GuardLoginViewProps } from './props'
|
|
16
|
-
|
|
17
|
-
import { useAuthClient } from '../Guard/authClient'
|
|
18
|
-
import { GuardModuleType } from '../Guard/module'
|
|
19
|
-
import { LoginMethods } from '../AuthingGuard/types'
|
|
20
|
-
import { IconFont } from '../IconFont'
|
|
21
|
-
import { ChangeLanguage } from '../ChangeLanguage'
|
|
22
|
-
import { i18n } from '../_utils/locales'
|
|
23
|
-
|
|
24
|
-
import './styles.less'
|
|
25
|
-
|
|
26
|
-
const inputWays = [
|
|
27
|
-
LoginMethods.Password,
|
|
28
|
-
LoginMethods.PhoneCode,
|
|
29
|
-
LoginMethods.AD,
|
|
30
|
-
LoginMethods.LDAP,
|
|
31
|
-
]
|
|
32
|
-
const qrcodeWays = [
|
|
33
|
-
LoginMethods.AppQr,
|
|
34
|
-
LoginMethods.WxMinQr,
|
|
35
|
-
LoginMethods.WechatMpQrcode,
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
const useMethods = (config: any) => {
|
|
39
|
-
let dlm = config?.defaultLoginMethod
|
|
40
|
-
let propsMethods = config?.loginMethods
|
|
41
|
-
|
|
42
|
-
if (!propsMethods?.includes(dlm)) {
|
|
43
|
-
dlm = propsMethods?.[0]
|
|
44
|
-
}
|
|
45
|
-
let renderInputWay = intersection(propsMethods, inputWays).length > 0
|
|
46
|
-
let renderQrcodeWay = intersection(propsMethods, qrcodeWays).length > 0
|
|
47
|
-
return [dlm, renderInputWay, renderQrcodeWay]
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const useDisables = (data: any) => {
|
|
51
|
-
let { disableResetPwd, disableRegister } = data.config
|
|
52
|
-
let { loginWay, autoRegister } = data
|
|
53
|
-
|
|
54
|
-
if (loginWay === LoginMethods.PhoneCode) {
|
|
55
|
-
disableResetPwd = true
|
|
56
|
-
}
|
|
57
|
-
if (loginWay === LoginMethods.LDAP) {
|
|
58
|
-
disableResetPwd = true
|
|
59
|
-
disableRegister = true
|
|
60
|
-
}
|
|
61
|
-
if (autoRegister === true) {
|
|
62
|
-
disableRegister = true
|
|
63
|
-
}
|
|
64
|
-
return { disableResetPwd, disableRegister }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const useSwitchStates = (loginWay: LoginMethods) => {
|
|
68
|
-
let switchText = i18n.t('login.scanLogin')
|
|
69
|
-
if (qrcodeWays.includes(loginWay)) {
|
|
70
|
-
switchText = i18n.t('login.moreWays')
|
|
71
|
-
}
|
|
72
|
-
let inputNone = !inputWays.includes(loginWay) ? 'none' : ''
|
|
73
|
-
let qrcodeNone = !qrcodeWays.includes(loginWay) ? 'none' : ''
|
|
74
|
-
|
|
75
|
-
return { switchText, inputNone, qrcodeNone }
|
|
76
|
-
}
|
|
77
|
-
export const GuardLoginView = (props: GuardLoginViewProps) => {
|
|
78
|
-
let [defaultMethod, renderInputWay, renderQrcodeWay] = useMethods(
|
|
79
|
-
props.config
|
|
80
|
-
)
|
|
81
|
-
const { t } = useTranslation()
|
|
82
|
-
const [loginWay, setLoginWay] = useState(defaultMethod)
|
|
83
|
-
const [canLoop, setCanLoop] = useState(false) // 允许轮询
|
|
84
|
-
const client = useAuthClient()
|
|
85
|
-
|
|
86
|
-
let publicKey = props.config?.publicKey!
|
|
87
|
-
// let autoRegister = props.config?.autoRegister
|
|
88
|
-
let ms = props.config?.loginMethods
|
|
89
|
-
let { autoRegister, langRange } = props.config
|
|
90
|
-
|
|
91
|
-
const firstInputWay = inputWays.filter((way) => ms.includes(way))[0]
|
|
92
|
-
const firstQRcodeWay = qrcodeWays.filter((way) => ms.includes(way))[0]
|
|
93
|
-
|
|
94
|
-
let { disableResetPwd, disableRegister } = useDisables({
|
|
95
|
-
config: props.config,
|
|
96
|
-
loginWay,
|
|
97
|
-
autoRegister,
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
const __codePaser = (code: number) => {
|
|
101
|
-
const action = codeMap[code]
|
|
102
|
-
if (code === 200) {
|
|
103
|
-
return (data: any) => {
|
|
104
|
-
props.onLogin?.(data, client!) // 登录成功
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (!action) {
|
|
109
|
-
return (initData?: any) => {
|
|
110
|
-
initData?._messag && message.error(initData?._messag)
|
|
111
|
-
console.error('未捕获 code', code)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// 解析成功
|
|
116
|
-
if (action?.action === 'changeModule') {
|
|
117
|
-
let m = action.module ? action.module : GuardModuleType.ERROR
|
|
118
|
-
let init = action.initData ? action.initData : {}
|
|
119
|
-
return (initData?: any) =>
|
|
120
|
-
props.__changeModule?.(m, { ...initData, ...init })
|
|
121
|
-
}
|
|
122
|
-
if (action?.action === 'message') {
|
|
123
|
-
return (initData?: any) => {
|
|
124
|
-
message.error(initData?._message)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// 最终结果
|
|
129
|
-
return (initData?: any) => {
|
|
130
|
-
// props.onLoginError?.(data, client!) // 未捕获 code
|
|
131
|
-
console.error('last action at loginview')
|
|
132
|
-
message.error(initData?._message)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const onLogin = (code: any, data: any, message?: string) => {
|
|
137
|
-
const callback = __codePaser?.(code)
|
|
138
|
-
if (code !== 200) {
|
|
139
|
-
props.onLoginError?.({
|
|
140
|
-
code,
|
|
141
|
-
data,
|
|
142
|
-
message,
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
if (!data) {
|
|
146
|
-
data = {}
|
|
147
|
-
}
|
|
148
|
-
data._message = message
|
|
149
|
-
callback?.(data)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const onBeforeLogin = (loginInfo: any) => {
|
|
153
|
-
if (props.onBeforeLogin) {
|
|
154
|
-
return props.onBeforeLogin?.(loginInfo, client)
|
|
155
|
-
}
|
|
156
|
-
return () => console.log('Guard not onBeforeLogin hooks')
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
if (qrcodeWays.includes(loginWay)) {
|
|
161
|
-
setCanLoop(true)
|
|
162
|
-
}
|
|
163
|
-
// 可以设定 = fasle 的时候关闭 qrcode 的几个定时器
|
|
164
|
-
// 不关的话,第二次进入会更快,也没什么代价(只有轮询)
|
|
165
|
-
}, [loginWay])
|
|
166
|
-
|
|
167
|
-
let { switchText, inputNone, qrcodeNone } = useSwitchStates(loginWay)
|
|
168
|
-
// if (loading) {
|
|
169
|
-
// return (
|
|
170
|
-
// <div className="g2-view-container">
|
|
171
|
-
// <LoadShielding />
|
|
172
|
-
// </div>
|
|
173
|
-
// )
|
|
174
|
-
// }
|
|
175
|
-
return (
|
|
176
|
-
<div className="g2-view-container">
|
|
177
|
-
{/* 两种方式都需要渲染的时候,才出现切换按钮 */}
|
|
178
|
-
{renderInputWay && renderQrcodeWay && (
|
|
179
|
-
<div className="g2-qrcode-switch">
|
|
180
|
-
<div className="switch-text">{switchText}</div>
|
|
181
|
-
<div
|
|
182
|
-
className="switch-img"
|
|
183
|
-
onClick={() => {
|
|
184
|
-
if (inputWays.includes(loginWay)) {
|
|
185
|
-
setLoginWay(firstQRcodeWay)
|
|
186
|
-
} else if (qrcodeWays.includes(loginWay)) {
|
|
187
|
-
setLoginWay(firstInputWay)
|
|
188
|
-
}
|
|
189
|
-
}}
|
|
190
|
-
>
|
|
191
|
-
<div className="imgae-mask" />
|
|
192
|
-
<IconFont
|
|
193
|
-
type="authing-a-erweima22"
|
|
194
|
-
className={`qrcode-switch-image ${inputNone}`}
|
|
195
|
-
/>
|
|
196
|
-
<IconFont
|
|
197
|
-
type="authing-diannao"
|
|
198
|
-
style={{ marginTop: '-6px' }}
|
|
199
|
-
className={`qrcode-switch-image ${qrcodeNone}`}
|
|
200
|
-
/>
|
|
201
|
-
</div>
|
|
202
|
-
</div>
|
|
203
|
-
)}
|
|
204
|
-
|
|
205
|
-
<div className="g2-view-header">
|
|
206
|
-
<img src={props.config?.logo} alt="" className="icon" />
|
|
207
|
-
<div className="title">
|
|
208
|
-
{t('common.login')} {props.config?.title}
|
|
209
|
-
</div>
|
|
210
|
-
</div>
|
|
211
|
-
|
|
212
|
-
{renderInputWay && (
|
|
213
|
-
<div className={inputNone}>
|
|
214
|
-
<div className={`g2-view-tabs`}>
|
|
215
|
-
<Tabs
|
|
216
|
-
onChange={(k: any) => {
|
|
217
|
-
setLoginWay(k)
|
|
218
|
-
props.onLoginTabChange?.(k)
|
|
219
|
-
}}
|
|
220
|
-
activeKey={loginWay}
|
|
221
|
-
>
|
|
222
|
-
{ms?.includes(LoginMethods.Password) && (
|
|
223
|
-
<Tabs.TabPane
|
|
224
|
-
key={LoginMethods.Password}
|
|
225
|
-
tab={t('login.pwdLogin')}
|
|
226
|
-
>
|
|
227
|
-
<LoginWithPassword
|
|
228
|
-
publicKey={publicKey}
|
|
229
|
-
autoRegister={autoRegister}
|
|
230
|
-
host={props.config.host}
|
|
231
|
-
onLogin={onLogin}
|
|
232
|
-
onBeforeLogin={onBeforeLogin}
|
|
233
|
-
passwordLoginMethods={props.config.passwordLoginMethods}
|
|
234
|
-
/>
|
|
235
|
-
</Tabs.TabPane>
|
|
236
|
-
)}
|
|
237
|
-
{ms?.includes(LoginMethods.PhoneCode) && (
|
|
238
|
-
<Tabs.TabPane
|
|
239
|
-
key={LoginMethods.PhoneCode}
|
|
240
|
-
tab={t('login.verifyCodeLogin')}
|
|
241
|
-
>
|
|
242
|
-
<LoginWithPhoneCode
|
|
243
|
-
verifyCodeLength={
|
|
244
|
-
props.config.__publicConfig__?.verifyCodeLength
|
|
245
|
-
}
|
|
246
|
-
autoRegister={autoRegister}
|
|
247
|
-
onBeforeLogin={onBeforeLogin}
|
|
248
|
-
onLogin={onLogin}
|
|
249
|
-
/>
|
|
250
|
-
</Tabs.TabPane>
|
|
251
|
-
)}
|
|
252
|
-
{ms?.includes(LoginMethods.LDAP) && (
|
|
253
|
-
<Tabs.TabPane
|
|
254
|
-
key={LoginMethods.LDAP}
|
|
255
|
-
tab={t('login.ldapLogin')}
|
|
256
|
-
>
|
|
257
|
-
<LoginWithLDAP
|
|
258
|
-
publicKey={publicKey}
|
|
259
|
-
autoRegister={autoRegister}
|
|
260
|
-
host={props.config.host}
|
|
261
|
-
onLogin={onLogin}
|
|
262
|
-
onBeforeLogin={onBeforeLogin}
|
|
263
|
-
/>
|
|
264
|
-
</Tabs.TabPane>
|
|
265
|
-
)}
|
|
266
|
-
{ms?.includes(LoginMethods.AD) && (
|
|
267
|
-
<Tabs.TabPane key={LoginMethods.AD} tab={t('login.adLogin')}>
|
|
268
|
-
<LoginWithAD onLogin={onLogin} />
|
|
269
|
-
</Tabs.TabPane>
|
|
270
|
-
)}
|
|
271
|
-
</Tabs>
|
|
272
|
-
</div>
|
|
273
|
-
<div className={`g2-tips-line`}>
|
|
274
|
-
{!disableResetPwd && (
|
|
275
|
-
<div>
|
|
276
|
-
<span
|
|
277
|
-
className="link-like"
|
|
278
|
-
onClick={() =>
|
|
279
|
-
props.__changeModule?.(GuardModuleType.FORGET_PWD, {})
|
|
280
|
-
}
|
|
281
|
-
>
|
|
282
|
-
{t('login.forgetPwd')}
|
|
283
|
-
</span>
|
|
284
|
-
<span style={{ margin: '0 4px' }} className="gray">
|
|
285
|
-
丨
|
|
286
|
-
</span>
|
|
287
|
-
</div>
|
|
288
|
-
)}
|
|
289
|
-
|
|
290
|
-
<div
|
|
291
|
-
className="touch-tip"
|
|
292
|
-
onClick={() =>
|
|
293
|
-
props.__changeModule?.(GuardModuleType.ANY_QUESTIONS, {})
|
|
294
|
-
}
|
|
295
|
-
>
|
|
296
|
-
<IconFont
|
|
297
|
-
type={'authing-a-question-line1'}
|
|
298
|
-
// style={{ fontSize: 20, marginRight: 8 }}
|
|
299
|
-
/>
|
|
300
|
-
</div>
|
|
301
|
-
|
|
302
|
-
{!disableRegister && (
|
|
303
|
-
<span className="go-to-register">
|
|
304
|
-
<span className="gray">{t('common.noAccYet')}</span>
|
|
305
|
-
<span
|
|
306
|
-
className="link-like"
|
|
307
|
-
onClick={() =>
|
|
308
|
-
props.__changeModule?.(GuardModuleType.REGISTER, {})
|
|
309
|
-
}
|
|
310
|
-
>
|
|
311
|
-
{t('common.registerImmediate')}
|
|
312
|
-
</span>
|
|
313
|
-
</span>
|
|
314
|
-
)}
|
|
315
|
-
</div>
|
|
316
|
-
</div>
|
|
317
|
-
)}
|
|
318
|
-
{renderQrcodeWay && (
|
|
319
|
-
<div className={`g2-view-tabs ${qrcodeNone}`}>
|
|
320
|
-
<Tabs
|
|
321
|
-
onChange={(k: any) => {
|
|
322
|
-
props.onLoginTabChange?.(k)
|
|
323
|
-
}}
|
|
324
|
-
>
|
|
325
|
-
{ms?.includes(LoginMethods.WxMinQr) && (
|
|
326
|
-
<Tabs.TabPane
|
|
327
|
-
key={LoginMethods.WxMinQr}
|
|
328
|
-
tab={t('login.scanLogin')}
|
|
329
|
-
>
|
|
330
|
-
<LoginWithWechatMiniQrcode
|
|
331
|
-
onLogin={onLogin}
|
|
332
|
-
canLoop={canLoop}
|
|
333
|
-
qrCodeScanOptions={props.config.qrCodeScanOptions}
|
|
334
|
-
/>
|
|
335
|
-
</Tabs.TabPane>
|
|
336
|
-
)}
|
|
337
|
-
{ms?.includes(LoginMethods.AppQr) && (
|
|
338
|
-
<Tabs.TabPane
|
|
339
|
-
key={LoginMethods.AppQr}
|
|
340
|
-
tab={t('login.appScanLogin')}
|
|
341
|
-
>
|
|
342
|
-
<LoginWithAppQrcode
|
|
343
|
-
onLogin={onLogin}
|
|
344
|
-
canLoop={canLoop}
|
|
345
|
-
qrCodeScanOptions={props.config.qrCodeScanOptions}
|
|
346
|
-
/>
|
|
347
|
-
</Tabs.TabPane>
|
|
348
|
-
)}
|
|
349
|
-
{ms?.includes(LoginMethods.WechatMpQrcode) && (
|
|
350
|
-
<Tabs.TabPane
|
|
351
|
-
key={LoginMethods.WechatMpQrcode}
|
|
352
|
-
tab={t('login.wechatmpQrcode')}
|
|
353
|
-
>
|
|
354
|
-
<LoginWithWechatmpQrcode
|
|
355
|
-
onLogin={onLogin}
|
|
356
|
-
canLoop={canLoop}
|
|
357
|
-
qrCodeScanOptions={props.config.qrCodeScanOptions}
|
|
358
|
-
/>
|
|
359
|
-
</Tabs.TabPane>
|
|
360
|
-
)}
|
|
361
|
-
</Tabs>
|
|
362
|
-
</div>
|
|
363
|
-
)}
|
|
364
|
-
<div className="g2-social-login">
|
|
365
|
-
<SocialLogin
|
|
366
|
-
appId={props.appId}
|
|
367
|
-
config={props.config}
|
|
368
|
-
onLogin={onLogin}
|
|
369
|
-
/>
|
|
370
|
-
</div>
|
|
371
|
-
<ChangeLanguage langRange={langRange} onLangChange={props.onLangChange} />
|
|
372
|
-
</div>
|
|
373
|
-
)
|
|
374
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDefaultG2Config,
|
|
3
|
-
IG2Config,
|
|
4
|
-
IG2Events,
|
|
5
|
-
IG2FCProps,
|
|
6
|
-
IG2FCViewProps,
|
|
7
|
-
} from '../Type'
|
|
8
|
-
import { SocialConnectionProvider } from 'authing-js-sdk'
|
|
9
|
-
import { QrCodeAuthenticationClient } from 'authing-js-sdk/build/main/lib/authentication/QrCodeAuthenticationClient'
|
|
10
|
-
import { PasswordLoginMethods } from '../AuthingGuard/api'
|
|
11
|
-
import {
|
|
12
|
-
PasswordLoginParams,
|
|
13
|
-
LDAPLoginParams,
|
|
14
|
-
ADLoginParams,
|
|
15
|
-
PhoneCodeLoginParams,
|
|
16
|
-
AuthenticationClient,
|
|
17
|
-
LoginMethods,
|
|
18
|
-
User,
|
|
19
|
-
} from '..'
|
|
20
|
-
|
|
21
|
-
export interface LoginConfig extends IG2Config {
|
|
22
|
-
autoRegister: boolean
|
|
23
|
-
disableResetPwd: boolean
|
|
24
|
-
disableRegister: boolean
|
|
25
|
-
defaultLoginMethod: LoginMethods
|
|
26
|
-
loginMethods: LoginMethods[]
|
|
27
|
-
passwordLoginMethods: PasswordLoginMethods[]
|
|
28
|
-
socialConnections?: SocialConnectionProvider[]
|
|
29
|
-
socialConnectionsBtnShape?: 'default' | 'button' | 'icon'
|
|
30
|
-
enterpriseConnections?: string[]
|
|
31
|
-
qrCodeScanOptions?: Parameters<QrCodeAuthenticationClient['startScanning']>[1]
|
|
32
|
-
publicKey?: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const defaultConfig: LoginConfig = {
|
|
36
|
-
...getDefaultG2Config(),
|
|
37
|
-
autoRegister: false,
|
|
38
|
-
disableResetPwd: false,
|
|
39
|
-
disableRegister: false,
|
|
40
|
-
defaultLoginMethod: LoginMethods.Password,
|
|
41
|
-
loginMethods: [LoginMethods.Password, LoginMethods.PhoneCode],
|
|
42
|
-
socialConnectionsBtnShape: 'default',
|
|
43
|
-
passwordLoginMethods: [
|
|
44
|
-
'email-password',
|
|
45
|
-
'username-password',
|
|
46
|
-
'phone-password',
|
|
47
|
-
],
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface LoginEvents extends IG2Events {
|
|
51
|
-
onLogin?: (user: User, authClient: AuthenticationClient) => void
|
|
52
|
-
onLoginError?: (errorMessages: any) => void
|
|
53
|
-
onLoginTabChange?: (activeTab: LoginMethods) => void
|
|
54
|
-
onBeforeLogin?: (
|
|
55
|
-
loginInfo:
|
|
56
|
-
| PasswordLoginParams
|
|
57
|
-
| LDAPLoginParams
|
|
58
|
-
| ADLoginParams
|
|
59
|
-
| PhoneCodeLoginParams,
|
|
60
|
-
authClient: AuthenticationClient
|
|
61
|
-
) => boolean | Promise<boolean>
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface GuardLoginProps extends IG2FCProps, LoginEvents {
|
|
65
|
-
config?: Partial<LoginConfig>
|
|
66
|
-
}
|
|
67
|
-
export interface GuardLoginViewProps extends GuardLoginProps, IG2FCViewProps {
|
|
68
|
-
config: LoginConfig
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export const getDefaultLoginConfig = (): LoginConfig => ({
|
|
72
|
-
...getDefaultG2Config(),
|
|
73
|
-
...defaultConfig,
|
|
74
|
-
})
|