@authing/react-ui-components 3.0.2-alpha → 3.0.2-beta.11

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 (253) hide show
  1. package/lib/index.d.ts +658 -108
  2. package/lib/index.min.css +2 -2
  3. package/lib/index.min.js +1 -1
  4. package/package.json +27 -9
  5. package/.eslintignore +0 -6
  6. package/.eslintrc.js +0 -7
  7. package/.prettierrc +0 -5
  8. package/.vscode/settings.json +0 -31
  9. package/build/asset-manifest.json +0 -26
  10. package/build/favicon.ico +0 -0
  11. package/build/index.html +0 -1
  12. package/build/logo192.png +0 -0
  13. package/build/logo512.png +0 -0
  14. package/build/manifest.json +0 -25
  15. package/build/robots.txt +0 -3
  16. package/build/static/css/2.31ae8f4c.chunk.css +0 -3
  17. package/build/static/css/2.31ae8f4c.chunk.css.map +0 -1
  18. package/build/static/css/main.0ff9e24a.chunk.css +0 -2
  19. package/build/static/css/main.0ff9e24a.chunk.css.map +0 -1
  20. package/build/static/js/2.1105ecfb.chunk.js +0 -3
  21. package/build/static/js/2.1105ecfb.chunk.js.LICENSE.txt +0 -102
  22. package/build/static/js/2.1105ecfb.chunk.js.map +0 -1
  23. package/build/static/js/3.fd17f196.chunk.js +0 -2
  24. package/build/static/js/3.fd17f196.chunk.js.map +0 -1
  25. package/build/static/js/main.ef2f91aa.chunk.js +0 -2
  26. package/build/static/js/main.ef2f91aa.chunk.js.map +0 -1
  27. package/build/static/js/runtime-main.ef138021.js +0 -2
  28. package/build/static/js/runtime-main.ef138021.js.map +0 -1
  29. package/build/static/media/loading.4a67a5f3.svg +0 -29
  30. package/components/AuthingDropdown/index.tsx +0 -52
  31. package/components/AuthingDropdown/style.less +0 -43
  32. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  33. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  34. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  35. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  36. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  37. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  38. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  39. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  40. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  41. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  42. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  43. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  44. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  45. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  46. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  47. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  48. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  49. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  50. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  51. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  52. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  53. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  54. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  55. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  56. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  57. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  58. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  59. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  60. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  61. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  62. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  63. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  64. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  65. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  66. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  67. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  68. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  69. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  70. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  71. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  72. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  73. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  74. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  75. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  76. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  77. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  78. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  79. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  80. package/components/AuthingGuard/Forms/index.ts +0 -13
  81. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  82. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  83. package/components/AuthingGuard/Header/index.tsx +0 -25
  84. package/components/AuthingGuard/Header/style.less +0 -52
  85. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  86. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  87. package/components/AuthingGuard/IconFont/style.less +0 -6
  88. package/components/AuthingGuard/IconFont/svg.js +0 -2
  89. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  90. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  91. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  92. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  93. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  94. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  95. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  96. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  97. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  98. package/components/AuthingGuard/api/appConfig.ts +0 -146
  99. package/components/AuthingGuard/api/index.ts +0 -3
  100. package/components/AuthingGuard/api/sso.ts +0 -29
  101. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  102. package/components/AuthingGuard/constants.ts +0 -105
  103. package/components/AuthingGuard/hooks/index.tsx +0 -70
  104. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  105. package/components/AuthingGuard/index.tsx +0 -126
  106. package/components/AuthingGuard/style.less +0 -103
  107. package/components/AuthingGuard/types/Forms.ts +0 -94
  108. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  109. package/components/AuthingGuard/types/GuardState.ts +0 -7
  110. package/components/AuthingGuard/types/Locales.ts +0 -12
  111. package/components/AuthingGuard/types/index.ts +0 -4
  112. package/components/AuthingTabs/index.tsx +0 -98
  113. package/components/AuthingTabs/style.less +0 -135
  114. package/components/BindTotp/core/bindSuccess.tsx +0 -61
  115. package/components/BindTotp/core/securityCode.tsx +0 -119
  116. package/components/BindTotp/index.tsx +0 -134
  117. package/components/BindTotp/interface.ts +0 -30
  118. package/components/BindTotp/styles.less +0 -57
  119. package/components/ChangeLanguage/index.tsx +0 -35
  120. package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
  121. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  122. package/components/ChangePassword/index.tsx +0 -59
  123. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  124. package/components/CompleteInfo/index.tsx +0 -45
  125. package/components/CompleteInfo/interface.ts +0 -40
  126. package/components/CompleteInfo/styles.less +0 -7
  127. package/components/CopyAbleText/index.tsx +0 -54
  128. package/components/CopyAbleText/style.less +0 -13
  129. package/components/DownloadAuthenticator/index.tsx +0 -97
  130. package/components/DownloadAuthenticator/interface.ts +0 -22
  131. package/components/DownloadAuthenticator/styles.less +0 -52
  132. package/components/Error/index.tsx +0 -21
  133. package/components/Error/interface.ts +0 -9
  134. package/components/Error/styles.less +0 -12
  135. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  136. package/components/ForgetPassword/index.tsx +0 -75
  137. package/components/ForgetPassword/interface.ts +0 -32
  138. package/components/Guard/Guard.tsx +0 -242
  139. package/components/Guard/authClient.ts +0 -55
  140. package/components/Guard/config.ts +0 -19
  141. package/components/Guard/event.ts +0 -52
  142. package/components/Guard/index.tsx +0 -4
  143. package/components/Guard/module.ts +0 -19
  144. package/components/Guard/stateMachine.ts +0 -133
  145. package/components/Guard/styles.less +0 -444
  146. package/components/IconFont/iconfont.js +0 -74
  147. package/components/IconFont/index.tsx +0 -16
  148. package/components/IconFont/style.less +0 -6
  149. package/components/IconFont/svg.js +0 -2
  150. package/components/ImagePro/index.tsx +0 -52
  151. package/components/ImagePro/styles.less +0 -40
  152. package/components/InputNumber/index.tsx +0 -33
  153. package/components/Login/codemap.ts +0 -39
  154. package/components/Login/core/withAD.tsx +0 -9
  155. package/components/Login/core/withAppQrcode.tsx +0 -49
  156. package/components/Login/core/withLDAP.tsx +0 -146
  157. package/components/Login/core/withPassword.tsx +0 -176
  158. package/components/Login/core/withPhonecode.tsx +0 -121
  159. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  160. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  161. package/components/Login/index.tsx +0 -368
  162. package/components/Login/props.ts +0 -74
  163. package/components/Login/socialLogin/index.tsx +0 -413
  164. package/components/Login/socialLogin/style.less +0 -61
  165. package/components/Login/styles.less +0 -53
  166. package/components/MFA/codemap.ts +0 -21
  167. package/components/MFA/core/email.tsx +0 -225
  168. package/components/MFA/core/face.tsx +0 -297
  169. package/components/MFA/core/face_deps.tsx +0 -37
  170. package/components/MFA/core/sms.tsx +0 -229
  171. package/components/MFA/core/totp.tsx +0 -137
  172. package/components/MFA/index.tsx +0 -137
  173. package/components/MFA/mfaMethods/index.tsx +0 -81
  174. package/components/MFA/mfaMethods/style.less +0 -39
  175. package/components/MFA/props.ts +0 -51
  176. package/components/MFA/styles.less +0 -93
  177. package/components/NeedHelpView/core/describeQuestions.tsx +0 -223
  178. package/components/NeedHelpView/index.tsx +0 -99
  179. package/components/RecoveryCode/core/useCode.tsx +0 -71
  180. package/components/RecoveryCode/index.tsx +0 -27
  181. package/components/RecoveryCode/interface.ts +0 -31
  182. package/components/RecoveryCode/style.less +0 -13
  183. package/components/Register/codemap.ts +0 -16
  184. package/components/Register/components/Agreements/index.tsx +0 -81
  185. package/components/Register/components/Agreements/style.less +0 -44
  186. package/components/Register/core/WithEmail.tsx +0 -236
  187. package/components/Register/core/WithPhone.tsx +0 -184
  188. package/components/Register/index.tsx +0 -123
  189. package/components/Register/props.ts +0 -50
  190. package/components/SendCode/SendCodeBtn.tsx +0 -96
  191. package/components/SendCode/index.tsx +0 -94
  192. package/components/SendCode/style.less +0 -31
  193. package/components/ShieldSpin/index.tsx +0 -27
  194. package/components/ShieldSpin/loading.svg +0 -29
  195. package/components/SubmitButton/index.tsx +0 -50
  196. package/components/Type/index.ts +0 -52
  197. package/components/ValidatorRules/EmailFormItem.tsx +0 -81
  198. package/components/ValidatorRules/PhoneFormItem.tsx +0 -90
  199. package/components/ValidatorRules/index.ts +0 -14
  200. package/components/VerifyCodeInput/index.tsx +0 -76
  201. package/components/VerifyCodeInput/style.less +0 -24
  202. package/components/_utils/GuardErrorCode.ts +0 -8
  203. package/components/_utils/clipboard.ts +0 -27
  204. package/components/_utils/config.ts +0 -121
  205. package/components/_utils/guradHttp.ts +0 -93
  206. package/components/_utils/hooks/index.ts +0 -64
  207. package/components/_utils/http.ts +0 -85
  208. package/components/_utils/index.ts +0 -319
  209. package/components/_utils/locales/en/common.json +0 -223
  210. package/components/_utils/locales/en/index.ts +0 -6
  211. package/components/_utils/locales/en/login.json +0 -96
  212. package/components/_utils/locales/en/map.json +0 -4
  213. package/components/_utils/locales/en/user.json +0 -82
  214. package/components/_utils/locales/index.ts +0 -45
  215. package/components/_utils/locales/zh/common.json +0 -223
  216. package/components/_utils/locales/zh/index.ts +0 -6
  217. package/components/_utils/locales/zh/login.json +0 -96
  218. package/components/_utils/locales/zh/map.json +0 -4
  219. package/components/_utils/locales/zh/user.json +0 -82
  220. package/components/_utils/popupCenter.ts +0 -48
  221. package/components/assets/images/error.png +0 -0
  222. package/components/context/base.tsx +0 -28
  223. package/components/context/global/context.tsx +0 -39
  224. package/components/context/global/reducer.tsx +0 -56
  225. package/components/context/module/context.tsx +0 -23
  226. package/components/index.ts +0 -12
  227. package/config/antdReplacer.js +0 -51
  228. package/config/env.js +0 -104
  229. package/config/getHttpsConfig.js +0 -66
  230. package/config/jest/cssTransform.js +0 -14
  231. package/config/jest/fileTransform.js +0 -40
  232. package/config/modules.js +0 -134
  233. package/config/paths.js +0 -71
  234. package/config/pnpTs.js +0 -35
  235. package/config/webpack.config.js +0 -835
  236. package/config/webpackDevServer.config.js +0 -130
  237. package/examples.tsx +0 -107
  238. package/index.js +0 -1
  239. package/logo.svg +0 -7
  240. package/public/favicon.ico +0 -0
  241. package/public/index.html +0 -43
  242. package/public/logo192.png +0 -0
  243. package/public/logo512.png +0 -0
  244. package/public/manifest.json +0 -25
  245. package/public/robots.txt +0 -3
  246. package/react-app-env.d.ts +0 -71
  247. package/reportWebVitals.ts +0 -15
  248. package/scripts/build.js +0 -208
  249. package/scripts/lib.js +0 -200
  250. package/scripts/start.js +0 -162
  251. package/scripts/test.js +0 -49
  252. package/setupTests.ts +0 -5
  253. package/tsconfig.json +0 -30
@@ -1,146 +0,0 @@
1
- import React, { useRef, useState } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { LockOutlined, UserOutlined } from '@ant-design/icons'
4
- import { Form, Input } from 'antd'
5
- import { LoginMethods } from '../../'
6
- import { ErrorCode } from '../../_utils/GuardErrorCode'
7
- import { useAuthClient } from '../../Guard/authClient'
8
- import SubmitButton from '../../SubmitButton'
9
- import { fieldRequiredRule } from '../../_utils'
10
-
11
- interface LoginWithLDAPProps {
12
- // configs
13
- publicKey: string
14
- autoRegister?: boolean
15
- host?: string
16
-
17
- // events
18
- onLogin: any
19
- onBeforeLogin: any
20
- }
21
-
22
- export const LoginWithLDAP = (props: LoginWithLDAPProps) => {
23
- let client = useAuthClient()
24
- const { t } = useTranslation()
25
- let submitButtonRef = useRef<any>(null)
26
-
27
- const [showCaptcha, setShowCaptcha] = useState(false)
28
- const [verifyCodeUrl, setVerifyCodeUrl] = useState('')
29
- const captchaUrl = `${props.host}/api/v2/security/captcha`
30
- const getCaptchaUrl = () => `${captchaUrl}?r=${+new Date()}`
31
-
32
- const onFinish = async (values: any) => {
33
- // onBeforeLogin
34
- submitButtonRef.current.onSpin(true)
35
- let loginInfo = {
36
- type: LoginMethods.LDAP,
37
- data: {
38
- identity: values.account,
39
- password: values.password,
40
- captchaCode: values.captchaCode,
41
- },
42
- }
43
- let context = await props.onBeforeLogin(loginInfo)
44
- if (!context) {
45
- submitButtonRef.current.onSpin(false)
46
- return
47
- }
48
-
49
- // onLogin
50
- let account = values.account && values.account.trim()
51
- let password = values.password && values.password.trim()
52
- let captchaCode = values.captchaCode && values.captchaCode.trim()
53
- try {
54
- const user = await client.loginByLdap(account, password, {
55
- autoRegister: props.autoRegister,
56
- captchaCode,
57
- })
58
- props.onLogin(200, user)
59
- } catch (error: any) {
60
- if (typeof error?.message === 'string') {
61
- let e = { code: 2333, data: {}, message: t('common.timeoutLDAP') }
62
- try {
63
- e = JSON.parse(error?.message)
64
- console.log('paser error.message error,cheke error', error)
65
- // onFail && onFail(errorData)
66
- submitButtonRef.current.onSpin(false)
67
- return
68
- } catch {}
69
- if (e.code === ErrorCode.INPUT_CAPTCHACODE) {
70
- setVerifyCodeUrl(getCaptchaUrl())
71
- setShowCaptcha(true)
72
- }
73
- submitButtonRef.current.onSpin(false)
74
- props.onLogin(e.code, e.data, e.message)
75
- // onFail && onFail(error)
76
- }
77
- }
78
- }
79
-
80
- return (
81
- <div className="authing-g2-login-ldap">
82
- <Form
83
- name="passworLogin"
84
- onFinish={onFinish}
85
- onFinishFailed={() => submitButtonRef.current.onError()}
86
- autoComplete="off"
87
- >
88
- <Form.Item
89
- className="authing-g2-input-form"
90
- name="account"
91
- rules={fieldRequiredRule(t('common.account'))}
92
- >
93
- <Input
94
- className="authing-g2-input"
95
- autoComplete="email,username,tel"
96
- size="large"
97
- placeholder={t('login.inputLdapUsername')}
98
- prefix={<UserOutlined style={{ color: '#878A95' }} />}
99
- />
100
- </Form.Item>
101
- <Form.Item
102
- className="authing-g2-input-form"
103
- name="password"
104
- rules={fieldRequiredRule(t('common.password'))}
105
- >
106
- <Input.Password
107
- className="authing-g2-input"
108
- size="large"
109
- placeholder={t('login.inputLdapPwd')}
110
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
111
- />
112
- </Form.Item>
113
- {showCaptcha && (
114
- <Form.Item
115
- className="authing-g2-input-form"
116
- name="captchaCode"
117
- rules={[{ required: true, message: t('login.inputCaptchaCode') }]}
118
- >
119
- <Input
120
- className="authing-g2-input add-after"
121
- size="large"
122
- placeholder={t('login.inputCaptchaCode')}
123
- addonAfter={
124
- <img
125
- className="g2-captcha-code-image"
126
- src={verifyCodeUrl}
127
- alt={t('login.captchaCode')}
128
- style={{ height: '2em', cursor: 'pointer' }}
129
- onClick={() => setVerifyCodeUrl(getCaptchaUrl())}
130
- />
131
- }
132
- />
133
- </Form.Item>
134
- )}
135
-
136
- <Form.Item>
137
- <SubmitButton
138
- text={t('common.login')}
139
- className="password"
140
- ref={submitButtonRef}
141
- />
142
- </Form.Item>
143
- </Form>
144
- </div>
145
- )
146
- }
@@ -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 { fieldRequiredRule, 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={fieldRequiredRule(t('common.account'))}
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={fieldRequiredRule(t('common.password'))}
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={fieldRequiredRule(t('common.captchaCode'))}
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,121 +0,0 @@
1
- import React, { useRef } from 'react'
2
- import { Form } from 'antd'
3
- import { useTranslation } from 'react-i18next'
4
- import { useAuthClient } from '../../Guard/authClient'
5
- import { UserOutlined, SafetyOutlined } from '@ant-design/icons'
6
- import { LoginMethods } from '../../'
7
- import { SendCode } from '../../SendCode'
8
- import { fieldRequiredRule } from '../../_utils'
9
- import SubmitButton from '../../SubmitButton'
10
- import { InputNumber } from '../../InputNumber'
11
- import { PhoneFormItem } from '../../ValidatorRules'
12
-
13
- // const formatPhone = (value: any) => {
14
- // if (!value) {
15
- // return ''
16
- // }
17
- // let a = value.slice(0, 3)
18
- // let b = value.slice(3, 7)
19
- // let c = value.slice(7, 11)
20
- // if (value.length < 4) {
21
- // return a
22
- // } else if (value.length < 8) {
23
- // return `${a}-${b}`
24
- // } else {
25
- // return `${a}-${b}-${c}`
26
- // }
27
- // }
28
- export const LoginWithPhoneCode = (props: any) => {
29
- let [form] = Form.useForm()
30
- let submitButtonRef = useRef<any>(null)
31
- const { t } = useTranslation()
32
-
33
- let client = useAuthClient()
34
-
35
- const verifyCodeLength = props.verifyCodeLength ?? 4
36
-
37
- const onFinish = async (values: any) => {
38
- submitButtonRef.current.onSpin(true)
39
- // onBeforeLogin
40
- let loginInfo = {
41
- type: LoginMethods.Password,
42
- data: {
43
- phone: values.phone,
44
- code: values.code,
45
- },
46
- }
47
- let context = await props.onBeforeLogin(loginInfo)
48
- if (!context) {
49
- submitButtonRef.current.onSpin(false)
50
- return
51
- }
52
-
53
- let loginContext = client.loginByPhoneCode(values.phone, values.code)
54
- loginContext
55
- .then((u) => {
56
- submitButtonRef.current.onSpin(false)
57
- props.onLogin(200, u)
58
- })
59
- .catch((e) => {
60
- submitButtonRef.current.onSpin(false)
61
- props.onLogin(e.code, e.data, e.message)
62
- })
63
- }
64
-
65
- return (
66
- <div className="authing-g2-login-phone-code">
67
- <Form
68
- name="phoneCode"
69
- form={form}
70
- onFinish={onFinish}
71
- onFinishFailed={() => submitButtonRef.current.onError()}
72
- autoComplete="off"
73
- >
74
- <PhoneFormItem className="authing-g2-input-form" name="phone">
75
- <InputNumber
76
- className="authing-g2-input"
77
- autoComplete="tel"
78
- type="tel"
79
- size="large"
80
- // 只有 InputNumber formatter、controls API
81
- // formatter={formatPhone}
82
- // parser={(value) => (value ? value.replaceAll('-', '') : '')}
83
- placeholder={t('login.inputPhone')}
84
- prefix={<UserOutlined style={{ color: '#878A95' }} />}
85
- />
86
- </PhoneFormItem>
87
- <Form.Item
88
- className="authing-g2-input-form"
89
- name="code"
90
- rules={fieldRequiredRule(t('common.captchaCode'))}
91
- >
92
- <SendCode
93
- className="authing-g2-input"
94
- autoComplete="one-time-code"
95
- size="large"
96
- placeholder={t('common.inputFourVerifyCode', {
97
- length: verifyCodeLength,
98
- })}
99
- maxLength={verifyCodeLength}
100
- prefix={<SafetyOutlined style={{ color: '#878A95' }} />}
101
- method="phone"
102
- data={''}
103
- form={form}
104
- onSendCodeBefore={() => form.validateFields(['phone'])}
105
- />
106
- </Form.Item>
107
- <Form.Item>
108
- <SubmitButton
109
- text={
110
- props.autoRegister
111
- ? `${t('common.login')} / ${t('common.register')}`
112
- : t('common.login')
113
- }
114
- className="password"
115
- ref={submitButtonRef}
116
- />
117
- </Form.Item>
118
- </Form>
119
- </div>
120
- )
121
- }
@@ -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
- }