@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,407 +0,0 @@
|
|
|
1
|
-
import { Button, message, Space, Tooltip } from 'antd'
|
|
2
|
-
import Avatar from 'antd/lib/avatar/avatar'
|
|
3
|
-
import { Protocol, SocialConnectionProvider } from 'authing-js-sdk'
|
|
4
|
-
import { Lang } from 'authing-js-sdk/build/main/types'
|
|
5
|
-
import qs from 'qs'
|
|
6
|
-
import React, { useEffect } from 'react'
|
|
7
|
-
import { useTranslation } from 'react-i18next'
|
|
8
|
-
import shortid from 'shortid'
|
|
9
|
-
import { i18n } from '../../_utils/locales'
|
|
10
|
-
import { isWechatBrowser, popupCenter } from '../../_utils'
|
|
11
|
-
import { useGuardHttp } from '../../_utils/guradHttp'
|
|
12
|
-
import {
|
|
13
|
-
ApplicationConfig,
|
|
14
|
-
IAzureAdConnectionConfig,
|
|
15
|
-
ICasConnectionConfig,
|
|
16
|
-
IOAuthConnectionConfig,
|
|
17
|
-
ISamlConnectionConfig,
|
|
18
|
-
OIDCConnectionConfig,
|
|
19
|
-
SocialConnectionItem,
|
|
20
|
-
} from '../../AuthingGuard/api'
|
|
21
|
-
import {
|
|
22
|
-
APP_MFA_CODE,
|
|
23
|
-
HIDE_SOCIALS,
|
|
24
|
-
OTP_MFA_CODE,
|
|
25
|
-
} from '../../AuthingGuard/constants'
|
|
26
|
-
import { useScreenSize } from '../../AuthingGuard/hooks/useScreenSize'
|
|
27
|
-
import { useAuthClient } from '../../Guard/authClient'
|
|
28
|
-
import { IconFont } from '../../IconFont'
|
|
29
|
-
import { LoginConfig } from '../props'
|
|
30
|
-
import './style.less'
|
|
31
|
-
|
|
32
|
-
export interface SocialLoginProps {
|
|
33
|
-
appId: string
|
|
34
|
-
config: LoginConfig
|
|
35
|
-
onLogin: any
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const SocialLogin: React.FC<SocialLoginProps> = ({
|
|
39
|
-
appId,
|
|
40
|
-
config,
|
|
41
|
-
onLogin: onGuardLogin,
|
|
42
|
-
}) => {
|
|
43
|
-
const noLoginMethods = !config.loginMethods.length
|
|
44
|
-
|
|
45
|
-
const userPoolId = config.__publicConfig__?.userPoolId
|
|
46
|
-
|
|
47
|
-
const publicConfig = config.__publicConfig__
|
|
48
|
-
|
|
49
|
-
const { t } = useTranslation()
|
|
50
|
-
|
|
51
|
-
const { post } = useGuardHttp()
|
|
52
|
-
|
|
53
|
-
const [screenSize] = useScreenSize()
|
|
54
|
-
|
|
55
|
-
const authClient = useAuthClient()
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
const onMessage = (evt: MessageEvent) => {
|
|
59
|
-
// TODO: event.origin是指发送的消息源,一定要进行验证!!!
|
|
60
|
-
|
|
61
|
-
const { code, message: errMsg, data, event } = evt.data
|
|
62
|
-
|
|
63
|
-
const { source, eventType } = event || {}
|
|
64
|
-
|
|
65
|
-
// 社会化登录是用 authing-js-sdk 实现的,不用再在这里回调了
|
|
66
|
-
if (source === 'authing' && eventType === 'socialLogin') {
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
const parsedMsg = JSON.parse(errMsg)
|
|
72
|
-
const { code: authingCode } = parsedMsg
|
|
73
|
-
if ([OTP_MFA_CODE, APP_MFA_CODE].includes(authingCode)) {
|
|
74
|
-
// onFail(parsedMsg)
|
|
75
|
-
// TODO
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
} catch (e) {
|
|
79
|
-
// do nothing...
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (code !== undefined) {
|
|
83
|
-
if (code === 200) {
|
|
84
|
-
localStorage.setItem('_authing_token', data?.token)
|
|
85
|
-
// onSuccess(data)
|
|
86
|
-
// TODO
|
|
87
|
-
} else {
|
|
88
|
-
message.error(errMsg)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
window.addEventListener('message', onMessage)
|
|
93
|
-
return () => {
|
|
94
|
-
window.removeEventListener('message', onMessage)
|
|
95
|
-
}
|
|
96
|
-
}, [])
|
|
97
|
-
|
|
98
|
-
let enterpriseConnectionObjs: ApplicationConfig['identityProviders']
|
|
99
|
-
|
|
100
|
-
if (config.enterpriseConnections) {
|
|
101
|
-
enterpriseConnectionObjs =
|
|
102
|
-
config.__publicConfig__?.identityProviders?.filter?.((item) =>
|
|
103
|
-
config.enterpriseConnections!.includes(item.identifier)
|
|
104
|
-
) || []
|
|
105
|
-
} else {
|
|
106
|
-
enterpriseConnectionObjs = config.__publicConfig__?.identityProviders || []
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const idpButtons = enterpriseConnectionObjs.map((i) => {
|
|
110
|
-
if (i.protocol === Protocol.OIDC) {
|
|
111
|
-
const configItem = i.config as OIDCConnectionConfig
|
|
112
|
-
const state = shortid.generate()
|
|
113
|
-
|
|
114
|
-
const query = qs.stringify({
|
|
115
|
-
client_id: configItem.clientId,
|
|
116
|
-
redirect_uri: configItem.redirectUri,
|
|
117
|
-
scope: configItem.scopes,
|
|
118
|
-
response_type: configItem.responseType,
|
|
119
|
-
state,
|
|
120
|
-
nonce: shortid.generate(),
|
|
121
|
-
})
|
|
122
|
-
const url = `${configItem.authorizationEdpoint}?${query}`
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<Button
|
|
126
|
-
key={i.identifier}
|
|
127
|
-
className="g2-guard-third-login-btn"
|
|
128
|
-
block
|
|
129
|
-
size="large"
|
|
130
|
-
icon={<Avatar size={20} src={i.logo} style={{ marginRight: 8 }} />}
|
|
131
|
-
onClick={async () => {
|
|
132
|
-
await post('/api/v2/connections/oidc/start-interaction', {
|
|
133
|
-
state,
|
|
134
|
-
protocol: i.protocol,
|
|
135
|
-
userPoolId,
|
|
136
|
-
appId,
|
|
137
|
-
referer: window.location.href,
|
|
138
|
-
connection: { providerIentifier: i.identifier },
|
|
139
|
-
})
|
|
140
|
-
popupCenter(url)
|
|
141
|
-
}}
|
|
142
|
-
>
|
|
143
|
-
{t('login.loginBy', {
|
|
144
|
-
name: i.displayName,
|
|
145
|
-
})}
|
|
146
|
-
</Button>
|
|
147
|
-
)
|
|
148
|
-
} else if (i.protocol === Protocol.SAML) {
|
|
149
|
-
const config = i.config as ISamlConnectionConfig
|
|
150
|
-
return (
|
|
151
|
-
<Button
|
|
152
|
-
key={i.identifier}
|
|
153
|
-
className="g2-guard-third-login-btn"
|
|
154
|
-
block
|
|
155
|
-
size="large"
|
|
156
|
-
icon={<Avatar size={20} src={i.logo} style={{ marginRight: 8 }} />}
|
|
157
|
-
onClick={async () => {
|
|
158
|
-
popupCenter(config.samlRequest!)
|
|
159
|
-
}}
|
|
160
|
-
>
|
|
161
|
-
{t('login.loginBy', {
|
|
162
|
-
name: i.displayName,
|
|
163
|
-
})}
|
|
164
|
-
</Button>
|
|
165
|
-
)
|
|
166
|
-
} else if (i.protocol === Protocol.CAS) {
|
|
167
|
-
const config = i.config as ICasConnectionConfig
|
|
168
|
-
|
|
169
|
-
return (
|
|
170
|
-
<Button
|
|
171
|
-
key={i.identifier}
|
|
172
|
-
className="g2-guard-third-login-btn"
|
|
173
|
-
block
|
|
174
|
-
size="large"
|
|
175
|
-
icon={<Avatar size={20} src={i.logo} style={{ marginRight: 8 }} />}
|
|
176
|
-
onClick={async () => {
|
|
177
|
-
popupCenter(config.casConnectionLoginUrl!)
|
|
178
|
-
}}
|
|
179
|
-
>
|
|
180
|
-
{t('login.loginBy', {
|
|
181
|
-
name: i.displayName,
|
|
182
|
-
})}
|
|
183
|
-
</Button>
|
|
184
|
-
)
|
|
185
|
-
} else if (i.protocol === Protocol.OAUTH) {
|
|
186
|
-
const config = i.config as IOAuthConnectionConfig
|
|
187
|
-
|
|
188
|
-
return (
|
|
189
|
-
<Button
|
|
190
|
-
key={i.identifier}
|
|
191
|
-
className="g2-guard-third-login-btn"
|
|
192
|
-
block
|
|
193
|
-
size="large"
|
|
194
|
-
icon={<Avatar size={20} src={i.logo} style={{ marginRight: 8 }} />}
|
|
195
|
-
onClick={async () => {
|
|
196
|
-
popupCenter(config.authUrl!)
|
|
197
|
-
}}
|
|
198
|
-
>
|
|
199
|
-
{t('login.loginBy', {
|
|
200
|
-
name: i.displayName,
|
|
201
|
-
})}
|
|
202
|
-
</Button>
|
|
203
|
-
)
|
|
204
|
-
} else if (i.protocol === Protocol.AZURE_AD) {
|
|
205
|
-
const configItem = i.config as IAzureAdConnectionConfig
|
|
206
|
-
return (
|
|
207
|
-
<Button
|
|
208
|
-
key={i.identifier}
|
|
209
|
-
className="g2-guard-third-login-btn"
|
|
210
|
-
block
|
|
211
|
-
size="large"
|
|
212
|
-
icon={<Avatar size={20} src={i.logo} style={{ marginRight: 8 }} />}
|
|
213
|
-
onClick={async () => {
|
|
214
|
-
popupCenter(configItem.authorizationUrl)
|
|
215
|
-
}}
|
|
216
|
-
>
|
|
217
|
-
{t('login.loginBy', {
|
|
218
|
-
name: i.displayName,
|
|
219
|
-
})}
|
|
220
|
-
</Button>
|
|
221
|
-
)
|
|
222
|
-
} else {
|
|
223
|
-
return null
|
|
224
|
-
}
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
let socialConnectionObjs: SocialConnectionItem[]
|
|
228
|
-
|
|
229
|
-
if (!config.socialConnections) {
|
|
230
|
-
socialConnectionObjs = [...(publicConfig?.socialConnections || [])]
|
|
231
|
-
} else {
|
|
232
|
-
const socials = config.socialConnections
|
|
233
|
-
socialConnectionObjs =
|
|
234
|
-
publicConfig?.socialConnections?.filter?.((item) =>
|
|
235
|
-
socials.includes(item.provider)
|
|
236
|
-
) ?? []
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// 某些社会化登录会在 tabs 中显示,或者无法在 Guard 中使用,所以底部不显示了
|
|
240
|
-
socialConnectionObjs = socialConnectionObjs?.filter(
|
|
241
|
-
(item) => !HIDE_SOCIALS.includes(item.provider)
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
const socialLoginButtons = socialConnectionObjs
|
|
245
|
-
.filter((item) =>
|
|
246
|
-
isWechatBrowser()
|
|
247
|
-
? item.provider === SocialConnectionProvider.WECHATMP
|
|
248
|
-
: item.provider !== SocialConnectionProvider.WECHATMP
|
|
249
|
-
)
|
|
250
|
-
.map((item) => {
|
|
251
|
-
const iconType = `authing-${item.provider.replace(/:/g, '-')}`
|
|
252
|
-
|
|
253
|
-
const authorization_params: Record<string, any> = {}
|
|
254
|
-
if (item.provider === SocialConnectionProvider.BAIDU) {
|
|
255
|
-
authorization_params.display = screenSize
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const onLogin = () => {
|
|
259
|
-
authClient.social.authorize(item.provider, {
|
|
260
|
-
onSuccess(user) {
|
|
261
|
-
// TODO
|
|
262
|
-
// onSuccess(user)
|
|
263
|
-
onGuardLogin(200, user)
|
|
264
|
-
},
|
|
265
|
-
onError(code, msg) {
|
|
266
|
-
try {
|
|
267
|
-
const parsedMsg = JSON.parse(msg)
|
|
268
|
-
const {
|
|
269
|
-
code: authingCode,
|
|
270
|
-
message: authingMessage,
|
|
271
|
-
data: authingData,
|
|
272
|
-
} = parsedMsg
|
|
273
|
-
// if ([OTP_MFA_CODE, APP_MFA_CODE].includes(authingCode)) {
|
|
274
|
-
// // TODO
|
|
275
|
-
// onGuardLogin(authingCode, authingData, authingMessage)
|
|
276
|
-
// return
|
|
277
|
-
// }
|
|
278
|
-
onGuardLogin(authingCode, authingData, authingMessage)
|
|
279
|
-
} catch (e) {
|
|
280
|
-
// do nothing...
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
message.error(msg)
|
|
284
|
-
},
|
|
285
|
-
authorization_params,
|
|
286
|
-
})
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const shape = config.socialConnectionsBtnShape
|
|
290
|
-
|
|
291
|
-
if (shape === 'button') {
|
|
292
|
-
return (
|
|
293
|
-
<Button
|
|
294
|
-
key={item.provider}
|
|
295
|
-
block
|
|
296
|
-
size="large"
|
|
297
|
-
className="g2-guard-third-login-btn"
|
|
298
|
-
icon={
|
|
299
|
-
<IconFont
|
|
300
|
-
type={`${iconType}-fill`}
|
|
301
|
-
style={{ fontSize: 20, marginRight: 8 }}
|
|
302
|
-
/>
|
|
303
|
-
}
|
|
304
|
-
onClick={onLogin}
|
|
305
|
-
style={{
|
|
306
|
-
marginBottom: 8,
|
|
307
|
-
}}
|
|
308
|
-
>
|
|
309
|
-
{i18n.language === 'zh-CN'
|
|
310
|
-
? item.name
|
|
311
|
-
: item.name_en ?? item.provider}
|
|
312
|
-
</Button>
|
|
313
|
-
)
|
|
314
|
-
} else if (shape === 'icon') {
|
|
315
|
-
return (
|
|
316
|
-
<Tooltip
|
|
317
|
-
key={item.provider}
|
|
318
|
-
title={item.tooltip?.[i18n.language as Lang] || item.name}
|
|
319
|
-
>
|
|
320
|
-
<div className="g2-social-login-item" onClick={onLogin}>
|
|
321
|
-
<IconFont type={`${iconType}-fill`} />
|
|
322
|
-
</div>
|
|
323
|
-
</Tooltip>
|
|
324
|
-
)
|
|
325
|
-
} else {
|
|
326
|
-
return noLoginMethods ? (
|
|
327
|
-
<Button
|
|
328
|
-
key={item.provider}
|
|
329
|
-
block
|
|
330
|
-
size="large"
|
|
331
|
-
className="g2-guard-third-login-btn"
|
|
332
|
-
icon={
|
|
333
|
-
<IconFont
|
|
334
|
-
type={`${iconType}-fill`}
|
|
335
|
-
style={{ fontSize: 20, marginRight: 8 }}
|
|
336
|
-
/>
|
|
337
|
-
}
|
|
338
|
-
onClick={onLogin}
|
|
339
|
-
>
|
|
340
|
-
{i18n.language === 'zh-CN'
|
|
341
|
-
? item.name
|
|
342
|
-
: item.name_en ?? item.provider}
|
|
343
|
-
</Button>
|
|
344
|
-
) : (
|
|
345
|
-
<Tooltip
|
|
346
|
-
key={item.provider}
|
|
347
|
-
title={item.tooltip?.[i18n.language as Lang] || item.name}
|
|
348
|
-
>
|
|
349
|
-
<div className="g2-social-login-item" onClick={onLogin}>
|
|
350
|
-
<IconFont type={`${iconType}-fill`} />
|
|
351
|
-
</div>
|
|
352
|
-
</Tooltip>
|
|
353
|
-
)
|
|
354
|
-
}
|
|
355
|
-
})
|
|
356
|
-
const idp =
|
|
357
|
-
enterpriseConnectionObjs.length > 0 ? (
|
|
358
|
-
<>
|
|
359
|
-
{!noLoginMethods && <div className="g2-social-login-title">OR</div>}
|
|
360
|
-
<div className="g2-social-login-list">{idpButtons}</div>
|
|
361
|
-
</>
|
|
362
|
-
) : null
|
|
363
|
-
|
|
364
|
-
// let socialLogin
|
|
365
|
-
// const shape = config.socialConnectionsBtnShape
|
|
366
|
-
|
|
367
|
-
const socialLogin =
|
|
368
|
-
socialLoginButtons.length > 0 && noLoginMethods ? (
|
|
369
|
-
<Space
|
|
370
|
-
size={12}
|
|
371
|
-
className="g2-guard-full-width-space no-login-methods"
|
|
372
|
-
direction="vertical"
|
|
373
|
-
>
|
|
374
|
-
{socialLoginButtons}
|
|
375
|
-
</Space>
|
|
376
|
-
) : (
|
|
377
|
-
socialLoginButtons.length > 0 && (
|
|
378
|
-
<>
|
|
379
|
-
<div className="g2-social-login-title">
|
|
380
|
-
{t('login.thridAccLogin')}
|
|
381
|
-
</div>
|
|
382
|
-
<div className="g2-social-login-list">{socialLoginButtons}</div>
|
|
383
|
-
</>
|
|
384
|
-
)
|
|
385
|
-
)
|
|
386
|
-
|
|
387
|
-
return (
|
|
388
|
-
<>
|
|
389
|
-
{!noLoginMethods && (
|
|
390
|
-
<div
|
|
391
|
-
style={{
|
|
392
|
-
flex: 1,
|
|
393
|
-
minHeight: 47,
|
|
394
|
-
}}
|
|
395
|
-
/>
|
|
396
|
-
)}
|
|
397
|
-
<Space
|
|
398
|
-
size={12}
|
|
399
|
-
direction="vertical"
|
|
400
|
-
className="g2-guard-full-width-space"
|
|
401
|
-
>
|
|
402
|
-
{idp}
|
|
403
|
-
{socialLogin}
|
|
404
|
-
</Space>
|
|
405
|
-
</>
|
|
406
|
-
)
|
|
407
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
.g2-guard-full-width-space {
|
|
2
|
-
width: 100%;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.no-login-methods {
|
|
6
|
-
padding: 38px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.g2-guard-third-login-btn {
|
|
10
|
-
display: flex !important;
|
|
11
|
-
|
|
12
|
-
border: none !important;
|
|
13
|
-
background-color: #f5f6f7 !important;
|
|
14
|
-
border-radius: 4px !important;
|
|
15
|
-
color: #282d3c !important;
|
|
16
|
-
font-size: 14px !important;
|
|
17
|
-
|
|
18
|
-
justify-content: center;
|
|
19
|
-
align-items: center;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.g2-social-login-item {
|
|
23
|
-
display: inline-flex;
|
|
24
|
-
margin: 12px;
|
|
25
|
-
width: 56px;
|
|
26
|
-
height: 48px;
|
|
27
|
-
background-color: #f5f6f7;
|
|
28
|
-
border-radius: 4px;
|
|
29
|
-
justify-content: center;
|
|
30
|
-
align-items: center;
|
|
31
|
-
cursor: pointer;
|
|
32
|
-
user-select: none;
|
|
33
|
-
|
|
34
|
-
.g2-icon {
|
|
35
|
-
font-size: 24px;
|
|
36
|
-
transition: color 0.3s ease-in-out;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&:hover {
|
|
40
|
-
background: rgba(84, 89, 104, 0.2);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.g2-social-login-title {
|
|
45
|
-
text-align: center;
|
|
46
|
-
font-size: 14px;
|
|
47
|
-
color: #c8c9cc;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.g2-social-login-title::before,
|
|
51
|
-
.g2-social-login-title::after {
|
|
52
|
-
content: '——';
|
|
53
|
-
color: #eeeeee;
|
|
54
|
-
margin: 0 11px;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.g2-social-login-list {
|
|
58
|
-
display: flex;
|
|
59
|
-
flex-wrap: wrap;
|
|
60
|
-
justify-content: center;
|
|
61
|
-
padding: 0 35px;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.authing-ant-avatar > img {
|
|
65
|
-
display: block;
|
|
66
|
-
width: 100%;
|
|
67
|
-
height: 100%;
|
|
68
|
-
object-fit: cover;
|
|
69
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
.g2-qrcode-switch {
|
|
2
|
-
position: absolute;
|
|
3
|
-
display: flex;
|
|
4
|
-
right: 16px;
|
|
5
|
-
|
|
6
|
-
.switch-text {
|
|
7
|
-
display: flex;
|
|
8
|
-
justify-content: center;
|
|
9
|
-
align-items: center;
|
|
10
|
-
background: rgba(84, 89, 104, 0.1);
|
|
11
|
-
height: 26px;
|
|
12
|
-
margin-right: 4px;
|
|
13
|
-
font-size: 12px;
|
|
14
|
-
padding: 0 12px;
|
|
15
|
-
border-radius: 4px;
|
|
16
|
-
color: #545968;
|
|
17
|
-
}
|
|
18
|
-
.switch-img {
|
|
19
|
-
&:hover {
|
|
20
|
-
.imgae-mask {
|
|
21
|
-
border-width: 0;
|
|
22
|
-
right: 50px;
|
|
23
|
-
top: 50px;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
.imgae-mask {
|
|
28
|
-
width: 0;
|
|
29
|
-
height: 0;
|
|
30
|
-
border-style: solid;
|
|
31
|
-
border-width: 50px 0 0 50px;
|
|
32
|
-
border-color: transparent transparent transparent #fff;
|
|
33
|
-
position: absolute;
|
|
34
|
-
right: 0;
|
|
35
|
-
top: 0;
|
|
36
|
-
transition: 0.2s all;
|
|
37
|
-
}
|
|
38
|
-
.qrcode-switch-image {
|
|
39
|
-
// width: 50px;
|
|
40
|
-
// height: 50px;
|
|
41
|
-
font-size: 50px;
|
|
42
|
-
color: #396aff;
|
|
43
|
-
cursor: pointer;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.authing-g2-login-app-qrcode {
|
|
48
|
-
min-height: 288px;
|
|
49
|
-
height: 300px;
|
|
50
|
-
display: flex;
|
|
51
|
-
justify-content: center;
|
|
52
|
-
align-items: center;
|
|
53
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import Form, { FormItemProps } from 'antd/lib/form'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { useTranslation } from 'react-i18next'
|
|
4
|
-
|
|
5
|
-
export interface VerifyCodeFormItemProps extends FormItemProps {
|
|
6
|
-
codeLength: number
|
|
7
|
-
ruleKeyword?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const VerifyCodeFormItem: React.FC<VerifyCodeFormItemProps> = (
|
|
11
|
-
props
|
|
12
|
-
) => {
|
|
13
|
-
const { t } = useTranslation()
|
|
14
|
-
const {
|
|
15
|
-
codeLength,
|
|
16
|
-
ruleKeyword = t('common.totpCode'),
|
|
17
|
-
...formItemProps
|
|
18
|
-
} = props
|
|
19
|
-
return (
|
|
20
|
-
<Form.Item
|
|
21
|
-
name="mfaCode"
|
|
22
|
-
className="g2-mfa-totp-verify-input"
|
|
23
|
-
// validateTrigger={'onBlur'}
|
|
24
|
-
rules={[
|
|
25
|
-
{
|
|
26
|
-
validator(_, value: string[]) {
|
|
27
|
-
if ((value ?? []).join('').length !== codeLength) {
|
|
28
|
-
return Promise.reject(
|
|
29
|
-
t('common.isMissing', {
|
|
30
|
-
name: ruleKeyword,
|
|
31
|
-
})
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
return Promise.resolve()
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
]}
|
|
38
|
-
{...formItemProps}
|
|
39
|
-
/>
|
|
40
|
-
)
|
|
41
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { Divider, Input } from 'antd'
|
|
2
|
-
import React, {
|
|
3
|
-
FC,
|
|
4
|
-
Fragment,
|
|
5
|
-
useCallback,
|
|
6
|
-
useEffect,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from 'react'
|
|
10
|
-
import './style.less'
|
|
11
|
-
|
|
12
|
-
interface VerifyCodeInputProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
13
|
-
length?: number
|
|
14
|
-
size?: string
|
|
15
|
-
gutter?: string
|
|
16
|
-
onEenter?: Function
|
|
17
|
-
showDivider?: boolean
|
|
18
|
-
onChange?: any
|
|
19
|
-
value?: Array<number | string>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const VerifyCodeInput: FC<VerifyCodeInputProps> = ({
|
|
23
|
-
length = 4,
|
|
24
|
-
size = '46px',
|
|
25
|
-
gutter = length > 4 ? '14px' : '24px',
|
|
26
|
-
className,
|
|
27
|
-
onEenter,
|
|
28
|
-
showDivider,
|
|
29
|
-
onChange,
|
|
30
|
-
value,
|
|
31
|
-
...rest
|
|
32
|
-
}) => {
|
|
33
|
-
const inputRef = useRef<any[]>([])
|
|
34
|
-
|
|
35
|
-
const codeInputRef = useRef<HTMLDivElement>(null)
|
|
36
|
-
|
|
37
|
-
const [verifyCode, setVerifyCode] = useState(value ?? [])
|
|
38
|
-
|
|
39
|
-
const handleChange = useCallback(
|
|
40
|
-
(val: string | undefined = '', index: number) => {
|
|
41
|
-
const num = parseInt(val)
|
|
42
|
-
if (isNaN(num)) {
|
|
43
|
-
val = ''
|
|
44
|
-
} else {
|
|
45
|
-
val = String(num)
|
|
46
|
-
}
|
|
47
|
-
const codes = [...verifyCode]
|
|
48
|
-
codes[index] = val.split('').slice(-1)[0] || ''
|
|
49
|
-
setVerifyCode(codes)
|
|
50
|
-
onChange?.(codes)
|
|
51
|
-
|
|
52
|
-
if (val && inputRef.current[index + 1]) {
|
|
53
|
-
inputRef.current[index + 1].focus()
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
[verifyCode, onChange]
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
const handleKeyDown = (evt: any, index: number) => {
|
|
60
|
-
const currentVal = verifyCode[index]
|
|
61
|
-
|
|
62
|
-
switch (evt.keyCode) {
|
|
63
|
-
case 8:
|
|
64
|
-
if (!currentVal && inputRef.current[index - 1]) {
|
|
65
|
-
handleChange('', index - 1)
|
|
66
|
-
inputRef.current[index - 1].focus()
|
|
67
|
-
}
|
|
68
|
-
break
|
|
69
|
-
|
|
70
|
-
case 13:
|
|
71
|
-
onEenter?.()
|
|
72
|
-
break
|
|
73
|
-
default:
|
|
74
|
-
break
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
const el = codeInputRef.current
|
|
80
|
-
|
|
81
|
-
const pasteEvent = (e: ClipboardEvent) => {
|
|
82
|
-
e.preventDefault()
|
|
83
|
-
e.stopPropagation()
|
|
84
|
-
|
|
85
|
-
let paste = e.clipboardData?.getData('text')
|
|
86
|
-
|
|
87
|
-
if (paste && !isNaN(parseInt(paste))) {
|
|
88
|
-
if (paste.length < length) {
|
|
89
|
-
const data = verifyCode.map((_i, index) => paste?.[index] ?? '')
|
|
90
|
-
setVerifyCode(data)
|
|
91
|
-
onChange?.(data)
|
|
92
|
-
inputRef.current[paste.length].focus()
|
|
93
|
-
} else {
|
|
94
|
-
const data = paste.slice(0, length).split('')
|
|
95
|
-
setVerifyCode(data)
|
|
96
|
-
onChange?.(data)
|
|
97
|
-
inputRef.current[length - 1].focus()
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
el?.addEventListener('paste', pasteEvent)
|
|
102
|
-
|
|
103
|
-
return () => {
|
|
104
|
-
el?.removeEventListener('paste', pasteEvent)
|
|
105
|
-
}
|
|
106
|
-
}, [length, onChange, setVerifyCode, verifyCode])
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<div ref={codeInputRef} className="authing-g2-code-input" {...rest}>
|
|
110
|
-
{new Array(length).fill(0).map((_, index) => (
|
|
111
|
-
<Fragment key={index}>
|
|
112
|
-
<Input
|
|
113
|
-
ref={(el) => (inputRef.current[index] = el)}
|
|
114
|
-
style={{
|
|
115
|
-
width: size,
|
|
116
|
-
minWidth: size,
|
|
117
|
-
minHeight: size,
|
|
118
|
-
height: size,
|
|
119
|
-
lineHeight: size,
|
|
120
|
-
marginLeft: index === 0 ? 0 : gutter,
|
|
121
|
-
}}
|
|
122
|
-
className="authing-g2-code-input-item"
|
|
123
|
-
size="large"
|
|
124
|
-
autoFocus={index === 0}
|
|
125
|
-
onKeyDown={(evt) => handleKeyDown(evt, index)}
|
|
126
|
-
value={verifyCode[index]}
|
|
127
|
-
onChange={(evt) => {
|
|
128
|
-
evt.persist()
|
|
129
|
-
// @ts-ignore
|
|
130
|
-
if (evt.nativeEvent.isComposing) {
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
handleChange(evt.target.value, index)
|
|
134
|
-
}}
|
|
135
|
-
pattern="[0-9]*"
|
|
136
|
-
type="tel"
|
|
137
|
-
/>
|
|
138
|
-
{showDivider && index === Math.floor(length / 2 - 1) && (
|
|
139
|
-
<Divider className="authing-g2-code-input-divider" />
|
|
140
|
-
)}
|
|
141
|
-
</Fragment>
|
|
142
|
-
))}
|
|
143
|
-
</div>
|
|
144
|
-
)
|
|
145
|
-
}
|