@authing/react-ui-components 3.0.0-alpha → 3.0.0-rc.3

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.
Files changed (232) hide show
  1. package/lib/index.d.ts +781 -110
  2. package/lib/index.min.css +2 -2
  3. package/lib/index.min.js +1 -1
  4. package/lib/index.min.js.LICENSE.txt +2 -0
  5. package/package.json +34 -12
  6. package/.eslintignore +0 -6
  7. package/.eslintrc.js +0 -7
  8. package/.prettierrc +0 -5
  9. package/.vscode/settings.json +0 -31
  10. package/build/favicon.ico +0 -0
  11. package/build/logo192.png +0 -0
  12. package/build/logo512.png +0 -0
  13. package/build/manifest.json +0 -25
  14. package/build/robots.txt +0 -3
  15. package/components/AuthingDropdown/index.tsx +0 -52
  16. package/components/AuthingDropdown/style.less +0 -43
  17. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  18. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  19. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  20. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  21. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  22. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  23. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  24. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  25. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  26. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  27. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  28. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  29. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  30. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  31. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  32. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  33. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  34. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  35. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  36. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  37. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  38. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  39. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  40. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  41. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  42. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  43. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  44. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  45. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  46. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  47. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  48. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  49. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  50. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  51. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  52. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  53. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  54. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  55. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  56. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  57. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  58. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  59. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  60. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  61. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  62. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  63. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  64. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  65. package/components/AuthingGuard/Forms/index.ts +0 -13
  66. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  67. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  68. package/components/AuthingGuard/Header/index.tsx +0 -25
  69. package/components/AuthingGuard/Header/style.less +0 -52
  70. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  71. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  72. package/components/AuthingGuard/IconFont/style.less +0 -6
  73. package/components/AuthingGuard/IconFont/svg.js +0 -2
  74. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  75. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  76. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  77. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  78. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  79. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  80. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  81. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  82. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  83. package/components/AuthingGuard/api/appConfig.ts +0 -146
  84. package/components/AuthingGuard/api/index.ts +0 -3
  85. package/components/AuthingGuard/api/sso.ts +0 -29
  86. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  87. package/components/AuthingGuard/constants.ts +0 -105
  88. package/components/AuthingGuard/hooks/index.tsx +0 -70
  89. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  90. package/components/AuthingGuard/index.tsx +0 -126
  91. package/components/AuthingGuard/style.less +0 -103
  92. package/components/AuthingGuard/types/Forms.ts +0 -94
  93. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  94. package/components/AuthingGuard/types/GuardState.ts +0 -7
  95. package/components/AuthingGuard/types/Locales.ts +0 -12
  96. package/components/AuthingGuard/types/index.ts +0 -4
  97. package/components/AuthingTabs/index.tsx +0 -98
  98. package/components/AuthingTabs/style.less +0 -135
  99. package/components/BindTotp/core/bindSuccess.tsx +0 -61
  100. package/components/BindTotp/core/securityCode.tsx +0 -119
  101. package/components/BindTotp/index.tsx +0 -134
  102. package/components/BindTotp/props.ts +0 -30
  103. package/components/BindTotp/styles.less +0 -56
  104. package/components/ChangeLanguage/index.tsx +0 -35
  105. package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
  106. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  107. package/components/ChangePassword/index.tsx +0 -59
  108. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  109. package/components/CompleteInfo/index.tsx +0 -45
  110. package/components/CompleteInfo/props.ts +0 -40
  111. package/components/CompleteInfo/styles.less +0 -7
  112. package/components/CompleteUserInfo/index.tsx +0 -49
  113. package/components/CompleteUserInfo/props.ts +0 -25
  114. package/components/ComponentsRender/index.back +0 -64
  115. package/components/CopyAbleText/index.tsx +0 -54
  116. package/components/CopyAbleText/style.less +0 -13
  117. package/components/DownloadAuthenticator/index.tsx +0 -97
  118. package/components/DownloadAuthenticator/props.ts +0 -22
  119. package/components/DownloadAuthenticator/styles.less +0 -52
  120. package/components/ForgetPassword/core/resetPassword.tsx +0 -150
  121. package/components/ForgetPassword/index.tsx +0 -51
  122. package/components/Guard/Guard.tsx +0 -226
  123. package/components/Guard/authClient.ts +0 -55
  124. package/components/Guard/config.ts +0 -19
  125. package/components/Guard/event.ts +0 -18
  126. package/components/Guard/index.tsx +0 -10
  127. package/components/Guard/module.ts +0 -19
  128. package/components/Guard/stateMachine.ts +0 -133
  129. package/components/Guard/styles.less +0 -444
  130. package/components/IconFont/iconfont.js +0 -74
  131. package/components/IconFont/index.tsx +0 -16
  132. package/components/IconFont/style.less +0 -6
  133. package/components/IconFont/svg.js +0 -2
  134. package/components/ImagePro/index.tsx +0 -52
  135. package/components/ImagePro/styles.less +0 -40
  136. package/components/Login/codemap.ts +0 -35
  137. package/components/Login/core/withAD.tsx +0 -9
  138. package/components/Login/core/withAppQrcode.tsx +0 -49
  139. package/components/Login/core/withLDAP.tsx +0 -145
  140. package/components/Login/core/withPassword.tsx +0 -176
  141. package/components/Login/core/withPhonecode.tsx +0 -135
  142. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  143. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  144. package/components/Login/index.tsx +0 -359
  145. package/components/Login/props.ts +0 -90
  146. package/components/Login/socialLogin/index.tsx +0 -413
  147. package/components/Login/socialLogin/style.less +0 -61
  148. package/components/Login/styles.less +0 -53
  149. package/components/MFA/codemap.ts +0 -21
  150. package/components/MFA/core/email.tsx +0 -226
  151. package/components/MFA/core/face.tsx +0 -297
  152. package/components/MFA/core/face_deps.tsx +0 -37
  153. package/components/MFA/core/sms.tsx +0 -222
  154. package/components/MFA/core/totp.tsx +0 -137
  155. package/components/MFA/index.tsx +0 -135
  156. package/components/MFA/mfaMethods/index.tsx +0 -81
  157. package/components/MFA/mfaMethods/style.less +0 -39
  158. package/components/MFA/props.ts +0 -51
  159. package/components/MFA/styles.less +0 -92
  160. package/components/NeedHelpView/core/describeQuestions.tsx +0 -227
  161. package/components/NeedHelpView/index.tsx +0 -99
  162. package/components/RecoveryCode/core/useCode.tsx +0 -71
  163. package/components/RecoveryCode/index.tsx +0 -27
  164. package/components/RecoveryCode/interface.ts +0 -31
  165. package/components/RecoveryCode/style.less +0 -13
  166. package/components/Register/codemap.ts +0 -16
  167. package/components/Register/components/Agreements/index.tsx +0 -81
  168. package/components/Register/components/Agreements/style.less +0 -44
  169. package/components/Register/core/WithEmail.tsx +0 -250
  170. package/components/Register/core/WithPhone.tsx +0 -190
  171. package/components/Register/index.tsx +0 -122
  172. package/components/Register/props.ts +0 -50
  173. package/components/SendCode/SendCodeBtn.tsx +0 -96
  174. package/components/SendCode/index.tsx +0 -98
  175. package/components/SendCode/style.less +0 -31
  176. package/components/ShieldSpin/index.tsx +0 -27
  177. package/components/ShieldSpin/loading.svg +0 -29
  178. package/components/SubmitButton/index.tsx +0 -50
  179. package/components/Type/index.ts +0 -61
  180. package/components/VerifyCodeInput/index.tsx +0 -76
  181. package/components/VerifyCodeInput/style.less +0 -24
  182. package/components/_utils/GuardErrorCode.ts +0 -8
  183. package/components/_utils/clipboard.ts +0 -27
  184. package/components/_utils/config.ts +0 -123
  185. package/components/_utils/guradHttp.ts +0 -93
  186. package/components/_utils/hooks/index.ts +0 -56
  187. package/components/_utils/http.ts +0 -85
  188. package/components/_utils/index.ts +0 -310
  189. package/components/_utils/locales/en/common.json +0 -218
  190. package/components/_utils/locales/en/index.ts +0 -6
  191. package/components/_utils/locales/en/login.json +0 -95
  192. package/components/_utils/locales/en/map.json +0 -4
  193. package/components/_utils/locales/en/user.json +0 -82
  194. package/components/_utils/locales/index.ts +0 -45
  195. package/components/_utils/locales/zh/common.json +0 -218
  196. package/components/_utils/locales/zh/index.ts +0 -6
  197. package/components/_utils/locales/zh/login.json +0 -95
  198. package/components/_utils/locales/zh/map.json +0 -4
  199. package/components/_utils/locales/zh/user.json +0 -82
  200. package/components/_utils/popupCenter.ts +0 -48
  201. package/components/context/base.tsx +0 -28
  202. package/components/context/global/context.tsx +0 -39
  203. package/components/context/global/reducer.tsx +0 -56
  204. package/components/context/module/context.tsx +0 -23
  205. package/components/index.ts +0 -10
  206. package/config/antdReplacer.js +0 -51
  207. package/config/env.js +0 -104
  208. package/config/getHttpsConfig.js +0 -66
  209. package/config/jest/cssTransform.js +0 -14
  210. package/config/jest/fileTransform.js +0 -40
  211. package/config/modules.js +0 -134
  212. package/config/paths.js +0 -71
  213. package/config/pnpTs.js +0 -35
  214. package/config/webpack.config.js +0 -835
  215. package/config/webpackDevServer.config.js +0 -130
  216. package/examples.tsx +0 -100
  217. package/index.js +0 -1
  218. package/logo.svg +0 -7
  219. package/public/favicon.ico +0 -0
  220. package/public/index.html +0 -43
  221. package/public/logo192.png +0 -0
  222. package/public/logo512.png +0 -0
  223. package/public/manifest.json +0 -25
  224. package/public/robots.txt +0 -3
  225. package/react-app-env.d.ts +0 -71
  226. package/reportWebVitals.ts +0 -15
  227. package/scripts/build.js +0 -208
  228. package/scripts/lib.js +0 -200
  229. package/scripts/start.js +0 -162
  230. package/scripts/test.js +0 -49
  231. package/setupTests.ts +0 -5
  232. package/tsconfig.json +0 -30
@@ -1,176 +0,0 @@
1
- import React, { useRef, useState } from 'react'
2
- import { Form, Input } from 'antd'
3
- import { UserOutlined, LockOutlined } from '@ant-design/icons'
4
- import { useTranslation } from 'react-i18next'
5
-
6
- import { useGuardHttp } from '../../_utils/guradHttp'
7
- import { useAuthClient } from '../../Guard/authClient'
8
- import { getUserRegisterParams } from '../../_utils'
9
- import { ErrorCode } from '../../_utils/GuardErrorCode'
10
- import { LoginMethods } from '../../'
11
- import SubmitButton from '../../SubmitButton'
12
-
13
- interface LoginWithPasswordProps {
14
- // configs
15
- publicKey: string
16
- autoRegister?: boolean
17
- host?: string
18
-
19
- // events
20
- onLogin: any
21
- onBeforeLogin: any
22
- }
23
-
24
- export const LoginWithPassword = (props: LoginWithPasswordProps) => {
25
- let { t } = useTranslation()
26
- let { post } = useGuardHttp()
27
- let client = useAuthClient()
28
-
29
- let submitButtonRef = useRef<any>(null)
30
-
31
- const [showCaptcha, setShowCaptcha] = useState(false)
32
- const [verifyCodeUrl, setVerifyCodeUrl] = useState('')
33
- const [remainCount, setRemainCount] = useState(0)
34
-
35
- const captchaUrl = `${props.host}/api/v2/security/captcha`
36
- const getCaptchaUrl = () => `${captchaUrl}?r=${+new Date()}`
37
-
38
- const encrypt = client.options.encryptFunction
39
-
40
- const onFinish = async (values: any) => {
41
- setRemainCount(0)
42
- // onBeforeLogin
43
- submitButtonRef.current.onSpin(true)
44
- let loginInfo = {
45
- type: LoginMethods.Password,
46
- data: {
47
- identity: values.account,
48
- password: values.password,
49
- captchaCode: values.captchaCode,
50
- },
51
- }
52
- let context = await props.onBeforeLogin(loginInfo)
53
- if (!context) {
54
- submitButtonRef.current.onSpin(false)
55
- return
56
- }
57
-
58
- // onLogin
59
- let url = '/api/v2/login/account'
60
- let account = values.account && values.account.trim()
61
- let password = values.password && values.password.trim()
62
- let captchaCode = values.captchaCode && values.captchaCode.trim()
63
-
64
- let body = {
65
- account: account,
66
- password: await encrypt!(password, props.publicKey),
67
- captchaCode,
68
- customData: getUserRegisterParams(),
69
- autoRegister: props.autoRegister,
70
- }
71
- const { code, message, data } = await post(url, body)
72
-
73
- if (code === ErrorCode.INPUT_CAPTCHACODE) {
74
- setVerifyCodeUrl(getCaptchaUrl())
75
- setShowCaptcha(true)
76
- }
77
- if (code === ErrorCode.PASSWORD_ERROR) {
78
- if ((data as any)?.remainCount) {
79
- setRemainCount((data as any)?.remainCount ?? 0)
80
- }
81
- }
82
- // if (Object.values(ErrorCode).includes(code)) {
83
- // setButtonContent('error')
84
- // }
85
- submitButtonRef.current.onSpin(false)
86
- props.onLogin(code, data, message)
87
- }
88
-
89
- return (
90
- <div className="authing-g2-login-password">
91
- <Form
92
- name="passworLogin"
93
- onFinish={onFinish}
94
- onFinishFailed={() => submitButtonRef.current.onError()}
95
- autoComplete="off"
96
- >
97
- <Form.Item
98
- name="account"
99
- className="authing-g2-input-form"
100
- rules={[{ required: true, message: t('common.accNotNull') }]}
101
- >
102
- <Input
103
- className="authing-g2-input"
104
- autoComplete="email,username,tel"
105
- size="large"
106
- placeholder={`${t('login.inputUsername')} / ${t(
107
- 'common.phoneNumber'
108
- )} / ${t('common.email')}`}
109
- prefix={<UserOutlined style={{ color: '#878A95' }} />}
110
- />
111
- </Form.Item>
112
- <Form.Item
113
- name="password"
114
- className="authing-g2-input-form"
115
- rules={[{ required: true, message: t('common.passwordNotNull') }]}
116
- >
117
- <Input.Password
118
- className="authing-g2-input"
119
- size="large"
120
- placeholder={t('login.inputLoginPwd')}
121
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
122
- />
123
- </Form.Item>
124
- {/* 图形验证码 */}
125
- {showCaptcha && (
126
- <Form.Item
127
- className="authing-g2-input-form"
128
- name="captchaCode"
129
- rules={[{ required: true, message: t('login.inputCaptchaCode') }]}
130
- >
131
- <Input
132
- className="authing-g2-input add-after"
133
- size="large"
134
- placeholder={t('login.inputCaptchaCode')}
135
- addonAfter={
136
- <img
137
- className="g2-captcha-code-image"
138
- src={verifyCodeUrl}
139
- alt={t('login.captchaCode')}
140
- style={{ height: '2em', cursor: 'pointer' }}
141
- onClick={() => setVerifyCodeUrl(getCaptchaUrl())}
142
- />
143
- }
144
- />
145
- </Form.Item>
146
- )}
147
- {remainCount !== 0 && (
148
- <span
149
- style={{
150
- marginBottom: 23,
151
- fontSize: 12,
152
- color: '#E63333',
153
- display: 'block',
154
- }}
155
- >
156
- {t('common.loginFailCheck', {
157
- number: remainCount,
158
- })}
159
- </span>
160
- )}
161
-
162
- <Form.Item>
163
- <SubmitButton
164
- text={
165
- props.autoRegister
166
- ? `${t('common.login')} / ${t('common.register')}`
167
- : t('common.login')
168
- }
169
- className="password"
170
- ref={submitButtonRef}
171
- />
172
- </Form.Item>
173
- </Form>
174
- </div>
175
- )
176
- }
@@ -1,135 +0,0 @@
1
- import React, { useRef } from 'react'
2
- import { Form, Input } from 'antd'
3
- import { useTranslation } from 'react-i18next'
4
- import { StoreValue } from 'antd/lib/form/interface'
5
- import { useAuthClient } from '../../Guard/authClient'
6
- import { UserOutlined, SafetyOutlined } from '@ant-design/icons'
7
- import { LoginMethods } from '../../'
8
- import { SendCode } from '../../SendCode'
9
- import { validate } from '../../_utils'
10
- import SubmitButton from '../../SubmitButton'
11
-
12
- // const formatPhone = (value: any) => {
13
- // if (!value) {
14
- // return ''
15
- // }
16
- // let a = value.slice(0, 3)
17
- // let b = value.slice(3, 7)
18
- // let c = value.slice(7, 11)
19
- // if (value.length < 4) {
20
- // return a
21
- // } else if (value.length < 8) {
22
- // return `${a}-${b}`
23
- // } else {
24
- // return `${a}-${b}-${c}`
25
- // }
26
- // }
27
- export const LoginWithPhoneCode = (props: any) => {
28
- let [form] = Form.useForm()
29
- let submitButtonRef = useRef<any>(null)
30
- const { t } = useTranslation()
31
-
32
- let client = useAuthClient()
33
-
34
- const onFinish = async (values: any) => {
35
- submitButtonRef.current.onSpin(true)
36
- // onBeforeLogin
37
- let loginInfo = {
38
- type: LoginMethods.Password,
39
- data: {
40
- phone: values.phone,
41
- code: values.code,
42
- },
43
- }
44
- let context = await props.onBeforeLogin(loginInfo)
45
- if (!context) {
46
- submitButtonRef.current.onSpin(false)
47
- return
48
- }
49
-
50
- let loginContext = client.loginByPhoneCode(values.phone, values.code)
51
- loginContext
52
- .then((u) => {
53
- submitButtonRef.current.onSpin(false)
54
- props.onLogin(200, u)
55
- })
56
- .catch((e) => {
57
- submitButtonRef.current.onSpin(false)
58
- props.onLogin(e.code, e.data, e.message)
59
- })
60
- }
61
-
62
- return (
63
- <div className="authing-g2-login-phone-code">
64
- <Form
65
- name="phoneCode"
66
- form={form}
67
- onFinish={onFinish}
68
- onFinishFailed={() => submitButtonRef.current.onError()}
69
- autoComplete="off"
70
- >
71
- <Form.Item
72
- className="authing-g2-input-form"
73
- name="phone"
74
- rules={[
75
- { required: true, message: t('login.inputPhone') },
76
- {
77
- validator: async (_, value: StoreValue) => {
78
- if (!value) {
79
- return
80
- }
81
- if (validate('phone', value)) {
82
- return
83
- } else {
84
- throw new Error(t('common.phoneFormateError'))
85
- }
86
- },
87
- },
88
- ]}
89
- >
90
- <Input
91
- className="authing-g2-input"
92
- autoComplete="tel"
93
- type="tel"
94
- size="large"
95
- // 只有 InputNumber formatter、controls API
96
- // formatter={formatPhone}
97
- // parser={(value) => (value ? value.replaceAll('-', '') : '')}
98
- placeholder={t('login.inputPhone')}
99
- prefix={<UserOutlined style={{ color: '#878A95' }} />}
100
- />
101
- </Form.Item>
102
- <Form.Item
103
- className="authing-g2-input-form"
104
- name="code"
105
- rules={[{ required: true, message: t('common.inputVerifyCode') }]}
106
- >
107
- <SendCode
108
- className="authing-g2-input"
109
- autoComplete="one-time-code"
110
- size="large"
111
- placeholder={t('common.inputFourVerifyCode', {
112
- length: 4,
113
- })}
114
- prefix={<SafetyOutlined style={{ color: '#878A95' }} />}
115
- method="phone"
116
- data={''}
117
- form={form}
118
- onSendCodeBefore={() => form.validateFields(['phone'])}
119
- />
120
- </Form.Item>
121
- <Form.Item>
122
- <SubmitButton
123
- text={
124
- props.autoRegister
125
- ? `${t('common.login')} / ${t('common.register')}`
126
- : t('common.login')
127
- }
128
- className="password"
129
- ref={submitButtonRef}
130
- />
131
- </Form.Item>
132
- </Form>
133
- </div>
134
- )
135
- }
@@ -1,60 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react'
2
- import { message } from 'antd'
3
- import { ShieldSpin } from '../../ShieldSpin'
4
- import { useAuthClient } from '../../Guard/authClient'
5
-
6
- interface LoginWithWechatMiniQrcodeProps {
7
- onLogin: any
8
- canLoop: boolean
9
- qrCodeScanOptions: any
10
- }
11
-
12
- export const LoginWithWechatMiniQrcode = (
13
- props: LoginWithWechatMiniQrcodeProps
14
- ) => {
15
- const timerRef = useRef<any>()
16
- const client = useAuthClient()
17
- const [loading, setLoading] = useState(true)
18
- const appQrcodeClient = client.wxqrcode
19
-
20
- useEffect(() => {
21
- return () => {
22
- clearInterval(timerRef.current)
23
- }
24
- }, [])
25
-
26
- useEffect(() => {
27
- if (!props.canLoop) {
28
- return
29
- }
30
- appQrcodeClient.startScanning('authingGuardMiniQrcode', {
31
- autoExchangeUserInfo: true,
32
- ...props.qrCodeScanOptions,
33
- onCodeLoaded() {
34
- setLoading(false)
35
- },
36
- onStart(timer) {
37
- // console.log('开始扫码')
38
- timerRef.current = timer
39
- },
40
- onSuccess(user) {
41
- // console.log('扫码完成', user)
42
- // onSuccess && onSuccess(user as User)
43
- props.onLogin(200, user)
44
- },
45
- onError: (ms) => {
46
- // config.qrCodeScanOptions?.onError?.(message)
47
- // onFail && onFail(`${message}`)
48
- message.error(ms)
49
- },
50
- })
51
- // eslint-disable-next-line react-hooks/exhaustive-deps
52
- }, [appQrcodeClient, props.canLoop, props.qrCodeScanOptions])
53
-
54
- return (
55
- <div className="authing-g2-login-app-qrcode">
56
- {loading && <ShieldSpin />}
57
- <div id="authingGuardMiniQrcode"></div>
58
- </div>
59
- )
60
- }
@@ -1,53 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react'
2
- import { ShieldSpin } from '../../ShieldSpin'
3
- import { useAuthClient } from '../../Guard/authClient'
4
-
5
- interface LoginWithWechatmpQrcodeProps {
6
- onLogin: any
7
- canLoop: boolean
8
- qrCodeScanOptions: any
9
- }
10
-
11
- export const LoginWithWechatmpQrcode = (
12
- props: LoginWithWechatmpQrcodeProps
13
- ) => {
14
- const timerRef = useRef<any>()
15
- const client = useAuthClient()
16
- const [loading, setLoading] = useState(true)
17
-
18
- const appQrcodeClient = client.wechatmpqrcode
19
- // const config = props.config
20
-
21
- useEffect(() => {
22
- if (!props.canLoop) {
23
- return
24
- }
25
- appQrcodeClient.startScanning('authingGuardMpQrcode', {
26
- autoExchangeUserInfo: true,
27
- ...props.qrCodeScanOptions,
28
- onCodeLoaded() {
29
- setLoading(false)
30
- },
31
- onStart(timer) {
32
- timerRef.current = timer
33
- },
34
- onSuccess(user) {
35
- props.onLogin(200, user)
36
- // onSuccess && onSuccess(user as User)
37
- },
38
- onError: (message) => {
39
- // config.qrCodeScanOptions?.onError?.(message)
40
- // onFail && onFail(`${message}`)
41
- },
42
- })
43
- return () => clearInterval(timerRef.current)
44
- // eslint-disable-next-line react-hooks/exhaustive-deps
45
- }, [appQrcodeClient, props.canLoop, props.qrCodeScanOptions])
46
-
47
- return (
48
- <div className="authing-g2-login-app-qrcode">
49
- {loading && <ShieldSpin />}
50
- <div id="authingGuardMpQrcode"></div>
51
- </div>
52
- )
53
- }