@authing/react-ui-components 3.0.2-beta.7 → 3.0.2-beta.9

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 (260) hide show
  1. package/lib/index.d.ts +2699 -0
  2. package/lib/index.min.css +2 -0
  3. package/lib/index.min.js +2 -0
  4. package/{build/static/js/2.142555a1.chunk.js.LICENSE.txt → lib/index.min.js.LICENSE.txt} +0 -33
  5. package/{build → lib}/static/media/loading.4a67a5f3.svg +0 -0
  6. package/package.json +25 -7
  7. package/.eslintignore +0 -6
  8. package/.eslintrc.js +0 -7
  9. package/.prettierrc +0 -5
  10. package/build/asset-manifest.json +0 -26
  11. package/build/favicon.ico +0 -0
  12. package/build/index.html +0 -1
  13. package/build/logo192.png +0 -0
  14. package/build/logo512.png +0 -0
  15. package/build/manifest.json +0 -25
  16. package/build/robots.txt +0 -3
  17. package/build/static/css/2.5c23c9b8.chunk.css +0 -3
  18. package/build/static/css/2.5c23c9b8.chunk.css.map +0 -1
  19. package/build/static/css/main.6a8701e8.chunk.css +0 -2
  20. package/build/static/css/main.6a8701e8.chunk.css.map +0 -1
  21. package/build/static/js/2.142555a1.chunk.js +0 -3
  22. package/build/static/js/2.142555a1.chunk.js.map +0 -1
  23. package/build/static/js/3.ed27e06b.chunk.js +0 -2
  24. package/build/static/js/3.ed27e06b.chunk.js.map +0 -1
  25. package/build/static/js/main.8d075e4d.chunk.js +0 -2
  26. package/build/static/js/main.8d075e4d.chunk.js.map +0 -1
  27. package/build/static/js/runtime-main.9a428724.js +0 -2
  28. package/build/static/js/runtime-main.9a428724.js.map +0 -1
  29. package/components/AuthingDropdown/index.tsx +0 -52
  30. package/components/AuthingDropdown/style.less +0 -43
  31. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  32. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  33. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  34. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  35. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  36. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  37. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  38. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  39. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  40. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  41. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  42. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  43. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  44. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  45. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  46. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  47. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  48. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  49. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  50. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  51. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  52. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  53. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  54. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  55. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  56. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  57. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  58. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  59. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  60. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  61. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  62. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  63. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  64. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  65. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  66. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  67. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  68. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  69. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  70. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  71. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  72. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  73. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  74. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  75. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  76. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  77. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  78. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  79. package/components/AuthingGuard/Forms/index.ts +0 -13
  80. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  81. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  82. package/components/AuthingGuard/Header/index.tsx +0 -25
  83. package/components/AuthingGuard/Header/style.less +0 -52
  84. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  85. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  86. package/components/AuthingGuard/IconFont/style.less +0 -6
  87. package/components/AuthingGuard/IconFont/svg.js +0 -2
  88. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  89. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  90. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  91. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  92. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  93. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  94. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  95. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  96. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  97. package/components/AuthingGuard/api/appConfig.ts +0 -146
  98. package/components/AuthingGuard/api/index.ts +0 -3
  99. package/components/AuthingGuard/api/sso.ts +0 -29
  100. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  101. package/components/AuthingGuard/constants.ts +0 -107
  102. package/components/AuthingGuard/hooks/index.tsx +0 -70
  103. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  104. package/components/AuthingGuard/index.tsx +0 -126
  105. package/components/AuthingGuard/style.less +0 -103
  106. package/components/AuthingGuard/types/Forms.ts +0 -94
  107. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  108. package/components/AuthingGuard/types/GuardState.ts +0 -7
  109. package/components/AuthingGuard/types/Locales.ts +0 -12
  110. package/components/AuthingGuard/types/index.ts +0 -4
  111. package/components/AuthingTabs/index.tsx +0 -98
  112. package/components/AuthingTabs/style.less +0 -135
  113. package/components/BindTotp/core/bindSuccess.tsx +0 -72
  114. package/components/BindTotp/core/securityCode.tsx +0 -108
  115. package/components/BindTotp/index.tsx +0 -134
  116. package/components/BindTotp/interface.ts +0 -30
  117. package/components/BindTotp/styles.less +0 -57
  118. package/components/ChangeLanguage/index.tsx +0 -35
  119. package/components/ChangePassword/core/firstLoginReset.tsx +0 -111
  120. package/components/ChangePassword/core/rotateReset.tsx +0 -125
  121. package/components/ChangePassword/index.tsx +0 -72
  122. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  123. package/components/CompleteInfo/index.tsx +0 -45
  124. package/components/CompleteInfo/interface.ts +0 -40
  125. package/components/CompleteInfo/styles.less +0 -7
  126. package/components/CopyAbleText/index.tsx +0 -54
  127. package/components/CopyAbleText/style.less +0 -13
  128. package/components/DownloadAuthenticator/index.tsx +0 -97
  129. package/components/DownloadAuthenticator/interface.ts +0 -22
  130. package/components/DownloadAuthenticator/styles.less +0 -52
  131. package/components/Error/index.tsx +0 -21
  132. package/components/Error/interface.ts +0 -9
  133. package/components/Error/styles.less +0 -12
  134. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  135. package/components/ForgetPassword/index.tsx +0 -78
  136. package/components/ForgetPassword/interface.ts +0 -32
  137. package/components/Guard/Guard.tsx +0 -295
  138. package/components/Guard/authClient.ts +0 -44
  139. package/components/Guard/config.ts +0 -19
  140. package/components/Guard/event.ts +0 -52
  141. package/components/Guard/index.tsx +0 -4
  142. package/components/Guard/module.ts +0 -20
  143. package/components/Guard/stateMachine.ts +0 -152
  144. package/components/Guard/styles.less +0 -461
  145. package/components/IconFont/iconfont.js +0 -74
  146. package/components/IconFont/index.tsx +0 -16
  147. package/components/IconFont/style.less +0 -6
  148. package/components/IconFont/svg.js +0 -2
  149. package/components/ImagePro/index.tsx +0 -53
  150. package/components/ImagePro/styles.less +0 -40
  151. package/components/InputNumber/index.tsx +0 -33
  152. package/components/Login/codemap.ts +0 -49
  153. package/components/Login/core/withAD.tsx +0 -9
  154. package/components/Login/core/withAppQrcode.tsx +0 -49
  155. package/components/Login/core/withLDAP.tsx +0 -146
  156. package/components/Login/core/withPassword/FormItemAccount.tsx +0 -42
  157. package/components/Login/core/withPassword/GraphicVerifyCode.tsx +0 -30
  158. package/components/Login/core/withPassword/InputAccount.tsx +0 -64
  159. package/components/Login/core/withPassword/index.tsx +0 -173
  160. package/components/Login/core/withPhonecode.tsx +0 -122
  161. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  162. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  163. package/components/Login/index.tsx +0 -374
  164. package/components/Login/interface.ts +0 -74
  165. package/components/Login/socialLogin/index.tsx +0 -407
  166. package/components/Login/socialLogin/style.less +0 -69
  167. package/components/Login/styles.less +0 -53
  168. package/components/MFA/VerifyCodeInput/VerifyCodeFormItem.tsx +0 -41
  169. package/components/MFA/VerifyCodeInput/index.tsx +0 -145
  170. package/components/MFA/VerifyCodeInput/style.less +0 -35
  171. package/components/MFA/codemap.ts +0 -24
  172. package/components/MFA/core/email.tsx +0 -203
  173. package/components/MFA/core/face.tsx +0 -297
  174. package/components/MFA/core/face_deps.tsx +0 -37
  175. package/components/MFA/core/sms.tsx +0 -203
  176. package/components/MFA/core/totp.tsx +0 -122
  177. package/components/MFA/index.tsx +0 -143
  178. package/components/MFA/interface.ts +0 -51
  179. package/components/MFA/mfaMethods/index.tsx +0 -88
  180. package/components/MFA/mfaMethods/style.less +0 -39
  181. package/components/MFA/styles.less +0 -100
  182. package/components/NeedHelpView/core/describeQuestions.tsx +0 -245
  183. package/components/NeedHelpView/index.tsx +0 -47
  184. package/components/RecoveryCode/core/useCode.tsx +0 -71
  185. package/components/RecoveryCode/index.tsx +0 -27
  186. package/components/RecoveryCode/interface.ts +0 -31
  187. package/components/RecoveryCode/style.less +0 -13
  188. package/components/Register/codemap.ts +0 -12
  189. package/components/Register/components/Agreements/index.tsx +0 -81
  190. package/components/Register/components/Agreements/style.less +0 -44
  191. package/components/Register/core/WithEmail.tsx +0 -242
  192. package/components/Register/core/WithPhone.tsx +0 -184
  193. package/components/Register/index.tsx +0 -139
  194. package/components/Register/interface.ts +0 -50
  195. package/components/SendCode/SendCodeBtn.tsx +0 -96
  196. package/components/SendCode/index.tsx +0 -94
  197. package/components/SendCode/style.less +0 -31
  198. package/components/ShieldSpin/index.tsx +0 -27
  199. package/components/ShieldSpin/loading.svg +0 -29
  200. package/components/SubmitButton/index.tsx +0 -50
  201. package/components/SubmitSuccess/index.tsx +0 -66
  202. package/components/SubmitSuccess/interface.ts +0 -17
  203. package/components/Type/index.ts +0 -52
  204. package/components/ValidatorRules/ValidatorFormItem.tsx +0 -139
  205. package/components/ValidatorRules/index.ts +0 -20
  206. package/components/VerifyCodeInput/index.tsx +0 -76
  207. package/components/VerifyCodeInput/style.less +0 -24
  208. package/components/_utils/GuardErrorCode.ts +0 -9
  209. package/components/_utils/clipboard.ts +0 -27
  210. package/components/_utils/config.ts +0 -116
  211. package/components/_utils/guradHttp.ts +0 -101
  212. package/components/_utils/hooks/index.ts +0 -64
  213. package/components/_utils/http.ts +0 -85
  214. package/components/_utils/index.ts +0 -326
  215. package/components/_utils/locales/en/common.json +0 -229
  216. package/components/_utils/locales/en/index.ts +0 -6
  217. package/components/_utils/locales/en/login.json +0 -96
  218. package/components/_utils/locales/en/map.json +0 -4
  219. package/components/_utils/locales/en/user.json +0 -82
  220. package/components/_utils/locales/index.ts +0 -45
  221. package/components/_utils/locales/zh/common.json +0 -229
  222. package/components/_utils/locales/zh/index.ts +0 -6
  223. package/components/_utils/locales/zh/login.json +0 -96
  224. package/components/_utils/locales/zh/map.json +0 -4
  225. package/components/_utils/locales/zh/user.json +0 -83
  226. package/components/_utils/popupCenter.ts +0 -48
  227. package/components/assets/images/error.png +0 -0
  228. package/components/context/base.tsx +0 -28
  229. package/components/context/global/context.tsx +0 -39
  230. package/components/context/global/reducer.tsx +0 -56
  231. package/components/context/module/context.tsx +0 -23
  232. package/components/index.ts +0 -9
  233. package/config/antdReplacer.js +0 -51
  234. package/config/env.js +0 -104
  235. package/config/getHttpsConfig.js +0 -66
  236. package/config/jest/cssTransform.js +0 -14
  237. package/config/jest/fileTransform.js +0 -40
  238. package/config/modules.js +0 -134
  239. package/config/paths.js +0 -71
  240. package/config/pnpTs.js +0 -35
  241. package/config/webpack.config.js +0 -835
  242. package/config/webpackDevServer.config.js +0 -130
  243. package/examples.tsx +0 -87
  244. package/index.js +0 -1
  245. package/logo.svg +0 -7
  246. package/public/favicon.ico +0 -0
  247. package/public/index.html +0 -43
  248. package/public/logo192.png +0 -0
  249. package/public/logo512.png +0 -0
  250. package/public/manifest.json +0 -25
  251. package/public/robots.txt +0 -3
  252. package/react-app-env.d.ts +0 -71
  253. package/reportWebVitals.ts +0 -15
  254. package/scripts/build.js +0 -208
  255. package/scripts/lib.js +0 -200
  256. package/scripts/publish.js +0 -57
  257. package/scripts/start.js +0 -162
  258. package/scripts/test.js +0 -49
  259. package/setupTests.ts +0 -5
  260. package/tsconfig.json +0 -30
@@ -1,133 +0,0 @@
1
- import React, { forwardRef, useImperativeHandle, useState } from 'react'
2
- import { FormInstance, Rule } from 'antd/lib/form'
3
- import { Alert, Form, Input, message } from 'antd'
4
- import { UserOutlined, SafetyOutlined } from '@ant-design/icons'
5
-
6
- import {
7
- getRequiredRules,
8
- getUserRegisterParams,
9
- VALIDATE_PATTERN,
10
- } from '../../../_utils'
11
- import { useGuardContext } from '../../../context/global/context'
12
- import {
13
- LoginMethods,
14
- PhoneCodeLoginFormProps,
15
- } from '../../../../components/AuthingGuard/types'
16
- import { SendPhoneCode } from '../../../../components/AuthingGuard/Forms/SendPhoneCode'
17
- import { LoginFormFooter } from '../../../../components/AuthingGuard/Forms/LoginFormFooter'
18
- import { useTranslation } from 'react-i18next'
19
-
20
- export const PhoneCodeLoginForm = forwardRef<
21
- FormInstance,
22
- PhoneCodeLoginFormProps
23
- >(({ onSuccess, onFail, onValidateFail }, ref) => {
24
- const {
25
- state: { authClient, config, guardEvents },
26
- } = useGuardContext()
27
- const { t } = useTranslation()
28
-
29
- const rulesMap: Record<string, Rule[]> = {
30
- phone: getRequiredRules(t('login.inputPhone')).concat({
31
- pattern: VALIDATE_PATTERN.phone,
32
- message: t('common.phoneFormateError'),
33
- }),
34
- code: getRequiredRules(t('common.inputVerifyCode')),
35
- }
36
-
37
- const [rawForm] = Form.useForm()
38
-
39
- const [phone, setPhone] = useState('')
40
- const [loading, setLoading] = useState(false)
41
-
42
- const onFinishFailed = (errorInfo: any) => {
43
- setLoading(false)
44
- onValidateFail && onValidateFail(errorInfo)
45
- }
46
-
47
- const onFinish = async (values: any) => {
48
- if (guardEvents.onBeforeLogin) {
49
- try {
50
- const canLogin = await guardEvents.onBeforeLogin(
51
- {
52
- type: LoginMethods.PhoneCode,
53
- data: {
54
- phone: values.phone,
55
- code: values.code,
56
- },
57
- },
58
- authClient
59
- )
60
-
61
- if (!canLogin) {
62
- setLoading(false)
63
- return
64
- }
65
- } catch (e) {
66
- if (typeof e === 'string') {
67
- message.error(e)
68
- } else {
69
- message.error(e.message)
70
- }
71
- setLoading(false)
72
- return
73
- }
74
- }
75
-
76
- try {
77
- const { phone, code } = values
78
- const user = await authClient.loginByPhoneCode(phone, code, {
79
- params: getUserRegisterParams(),
80
- })
81
- onSuccess && onSuccess(user)
82
- } catch (error) {
83
- onFail && onFail(error)
84
- } finally {
85
- setLoading(false)
86
- }
87
- }
88
-
89
- useImperativeHandle(ref, () => rawForm)
90
-
91
- return (
92
- <Form
93
- form={rawForm}
94
- onSubmitCapture={() => setLoading(true)}
95
- onFinishFailed={onFinishFailed}
96
- onFinish={onFinish}
97
- >
98
- {config.autoRegister && (
99
- <Alert
100
- message={t('login.phoneAutoRegister')}
101
- style={{ marginBottom: 24 }}
102
- />
103
- )}
104
- <Form.Item name="phone" rules={rulesMap.phone}>
105
- <Input
106
- autoComplete="tel"
107
- onChange={(e) => {
108
- setPhone(e.target.value)
109
- }}
110
- size="large"
111
- placeholder={t('login.inputPhone')}
112
- prefix={<UserOutlined style={{ color: '#ddd' }} />}
113
- />
114
- </Form.Item>
115
- <Form.Item name="code" rules={rulesMap.code}>
116
- <Input
117
- size="large"
118
- placeholder={t('common.inputFourVerifyCode', {
119
- length: 4,
120
- })}
121
- prefix={<SafetyOutlined style={{ color: '#ddd' }} />}
122
- suffix={<SendPhoneCode phone={phone} />}
123
- />
124
- </Form.Item>
125
-
126
- <LoginFormFooter
127
- needRestPwd
128
- needRegister
129
- loading={loading}
130
- ></LoginFormFooter>
131
- </Form>
132
- )
133
- })
@@ -1,202 +0,0 @@
1
- import { Input, Form, message } from 'antd'
2
- import { FormInstance } from 'antd/lib/form'
3
- import React, { forwardRef, useImperativeHandle, useState } from 'react'
4
- import { UserOutlined, LockOutlined, SafetyOutlined } from '@ant-design/icons'
5
-
6
- import { useGuardContext } from '../../../context/global/context'
7
- import {
8
- PhoneRegisterFormProps,
9
- RegisterMethods,
10
- } from '../../../../components/AuthingGuard/types'
11
- import {
12
- getDeviceName,
13
- getRequiredRules,
14
- getUserRegisterParams,
15
- VALIDATE_PATTERN,
16
- } from '../../../_utils'
17
- import { SendPhoneCode } from '../../../../components/AuthingGuard/Forms/SendPhoneCode'
18
- import { RegisterFormFooter } from '../../../../components/AuthingGuard/Forms/RegisterFormFooter'
19
- import { useTranslation } from 'react-i18next'
20
- import { Agreements } from '../Agreements'
21
-
22
- export const PhoneRegisterForm = forwardRef<
23
- FormInstance,
24
- PhoneRegisterFormProps
25
- >(({ onSuccess, onFail, onValidateFail }, ref) => {
26
- const {
27
- state: { authClient, config, guardEvents },
28
- } = useGuardContext()
29
- const { t } = useTranslation()
30
-
31
- const [rawForm] = Form.useForm()
32
-
33
- const { agreements, agreementEnabled } = config
34
-
35
- /** 表单是否被提交校验过 */
36
- const [validated, setValidated] = useState(false)
37
-
38
- const [phone, setPhone] = useState('')
39
- const [loading, setLoading] = useState(false)
40
-
41
- const onFinishFailed = (errorInfo: any) => {
42
- setLoading(false)
43
- onValidateFail && onValidateFail(errorInfo)
44
- }
45
-
46
- const [acceptedAgreements, setAcceptedAgreements] = useState(false)
47
-
48
- const onFinish = async (values: any) => {
49
- if (guardEvents.onBeforeRegister) {
50
- try {
51
- const canRegister = await guardEvents.onBeforeRegister(
52
- {
53
- type: RegisterMethods.Phone,
54
- data: {
55
- phone: values.phone,
56
- password: values.password,
57
- code: values.code,
58
- },
59
- },
60
- authClient
61
- )
62
-
63
- if (!canRegister) {
64
- setLoading(false)
65
- return
66
- }
67
- } catch (e) {
68
- if (typeof e === 'string') {
69
- message.error(e)
70
- } else {
71
- message.error(e.message)
72
- }
73
- setLoading(false)
74
- return
75
- }
76
- }
77
-
78
- try {
79
- await rawForm.validateFields()
80
-
81
- setValidated(true)
82
-
83
- if (agreementEnabled && agreements?.length && !acceptedAgreements) {
84
- return
85
- }
86
-
87
- const { phone, code, password } = values
88
- const user = await authClient.registerByPhoneCode(
89
- phone,
90
- code,
91
- password,
92
- {
93
- browser:
94
- typeof navigator !== 'undefined' ? navigator.userAgent : null,
95
- device: getDeviceName(),
96
- },
97
- {
98
- generateToken: true,
99
- params: getUserRegisterParams(),
100
- }
101
- )
102
- onSuccess && onSuccess(user)
103
- } catch (error) {
104
- onFail && onFail(error)
105
- } finally {
106
- setLoading(false)
107
- }
108
- }
109
-
110
- useImperativeHandle(ref, () => rawForm)
111
-
112
- const formItems = [
113
- {
114
- component: (
115
- <Input
116
- autoComplete="tel"
117
- onChange={(e) => {
118
- setPhone(e.target.value)
119
- }}
120
- size="large"
121
- placeholder={t('login.inputPhone')}
122
- prefix={<UserOutlined style={{ color: '#ddd' }} />}
123
- />
124
- ),
125
- name: 'phone',
126
- rules: getRequiredRules(t('common.phoneNotNull')).concat({
127
- pattern: VALIDATE_PATTERN.phone,
128
- message: t('login.phoneError'),
129
- }),
130
- },
131
- {
132
- component: (
133
- <Input.Password
134
- size="large"
135
- placeholder={t('common.setPassword')}
136
- prefix={<LockOutlined style={{ color: '#ddd' }} />}
137
- />
138
- ),
139
- name: 'password',
140
- rules: getRequiredRules(t('common.passwordNotNull')),
141
- },
142
- {
143
- component: (
144
- <Input.Password
145
- size="large"
146
- placeholder={t('login.inputPwdAgain')}
147
- prefix={<LockOutlined style={{ color: '#ddd' }} />}
148
- />
149
- ),
150
- name: 'new-password',
151
- rules: getRequiredRules(t('common.repeatPassword')).concat({
152
- validator: (rule, value) => {
153
- if (value !== rawForm.getFieldValue('password')) {
154
- return Promise.reject(t('common.repeatPasswordDoc'))
155
- } else {
156
- return Promise.resolve()
157
- }
158
- },
159
- }),
160
- },
161
- {
162
- component: (
163
- <Input
164
- autoComplete="one-time-code"
165
- size="large"
166
- placeholder={t('common.inputFourVerifyCode', {
167
- length: 4,
168
- })}
169
- prefix={<SafetyOutlined style={{ color: '#ddd' }} />}
170
- addonAfter={<SendPhoneCode phone={phone} />}
171
- />
172
- ),
173
- name: 'code',
174
- rules: getRequiredRules(t('common.captchaCodeNotNull')),
175
- },
176
- ]
177
-
178
- return (
179
- <Form
180
- form={rawForm}
181
- onSubmitCapture={() => setLoading(true)}
182
- onFinishFailed={onFinishFailed}
183
- onFinish={onFinish}
184
- >
185
- {formItems.map((item) => (
186
- <Form.Item name={item.name} key={item.name} rules={item.rules}>
187
- {item.component}
188
- </Form.Item>
189
- ))}
190
-
191
- {config.agreementEnabled && Boolean(agreements?.length) && (
192
- <Agreements
193
- onChange={setAcceptedAgreements}
194
- agreements={agreements}
195
- showError={validated}
196
- />
197
- )}
198
-
199
- <RegisterFormFooter loading={loading} />
200
- </Form>
201
- )
202
- })
@@ -1,59 +0,0 @@
1
- import { Spin } from 'antd'
2
- import React, { FC, useEffect, useMemo, useRef } from 'react'
3
-
4
- import { useGuardContext } from '../../../context/global/context'
5
- import {
6
- LoginMethods,
7
- QrLoginFormProps,
8
- } from '../../../../components/AuthingGuard/types'
9
-
10
- import './style.less'
11
- import { User } from 'authing-js-sdk'
12
-
13
- export const QrCodeLoginForm: FC<QrLoginFormProps> = ({
14
- onFail,
15
- onSuccess,
16
- type,
17
- }) => {
18
- const {
19
- state: { authClient, config },
20
- } = useGuardContext()
21
-
22
- const timerRef = useRef<any>()
23
-
24
- const client = useMemo(() => {
25
- return {
26
- [LoginMethods.AppQr]: authClient.qrcode,
27
- [LoginMethods.WxMinQr]: authClient.wxqrcode,
28
- [LoginMethods.WechatMpQrcode]: authClient.wechatmpqrcode,
29
- }[type]
30
- }, [type, authClient])
31
-
32
- useEffect(() => {
33
- client.startScanning('authingGuardQrcode', {
34
- autoExchangeUserInfo: true,
35
- ...config.qrCodeScanOptions,
36
- onStart(timer) {
37
- timerRef.current = timer
38
- },
39
- onSuccess(user) {
40
- onSuccess && onSuccess(user as User)
41
- },
42
- onError: (message) => {
43
- config.qrCodeScanOptions?.onError?.(message)
44
-
45
- onFail && onFail(`${message}`)
46
- },
47
- })
48
- return () => clearInterval(timerRef.current)
49
- }, [client, config.qrCodeScanOptions, onFail, onSuccess])
50
-
51
- return (
52
- <div className="authing-guard-qr-form">
53
- <div className="authing-guard-qr-loading">
54
- <Spin size="large" />
55
- </div>
56
- <div id="authingGuardQrcode"></div>
57
- </div>
58
- )
59
- }
@@ -1,14 +0,0 @@
1
- .authing-guard-qr-form {
2
- position: relative;
3
- min-height: 300px;
4
- }
5
- .authing-guard-qr-loading {
6
- position: absolute;
7
- width: 100%;
8
- height: 100%;
9
- left: 0;
10
- top: 0;
11
- display: flex;
12
- justify-content: center;
13
- align-items: center;
14
- }
@@ -1,56 +0,0 @@
1
- import { Button } from 'antd'
2
- import React, { FC } from 'react'
3
- import { useGuardContext } from '../../../context/global/context'
4
- import { GuardScenes } from '../../../../components/AuthingGuard/types'
5
-
6
- import './style.less'
7
- import { useTranslation } from 'react-i18next'
8
-
9
- export interface RegisterFormFooterProps {
10
- loading: boolean
11
- }
12
-
13
- export const RegisterFormFooter: FC<RegisterFormFooterProps> = ({
14
- loading,
15
- }) => {
16
- const {
17
- setValue,
18
- state: { config },
19
- } = useGuardContext()
20
- const { t } = useTranslation()
21
-
22
- return (
23
- <>
24
- <Button
25
- htmlType="submit"
26
- size="large"
27
- type="primary"
28
- loading={loading}
29
- block
30
- >
31
- {loading
32
- ? t(
33
- `map.${config.text?.registerBtn?.loading}`,
34
- config.text?.registerBtn?.loading
35
- )
36
- : t(
37
- `map.${config.text?.registerBtn?.normal}`,
38
- config.text?.registerBtn?.normal
39
- )}
40
- </Button>
41
-
42
- <div className="authing-guard-form-actions">
43
- <div className="authing-guard-tip-btn-comb">
44
- <span className="authing-guard-tip">{t('common.alreadyHasAcc')}</span>
45
- <Button
46
- onClick={() => setValue('guardScenes', GuardScenes.Login)}
47
- className="authing-guard-text-btn authing-guard-to-login-btn"
48
- type="text"
49
- >
50
- {t('common.loginImmediate')}
51
- </Button>
52
- </div>
53
- </div>
54
- </>
55
- )
56
- }
@@ -1,21 +0,0 @@
1
- import React from 'react'
2
- import { Button } from 'antd'
3
-
4
- import { useGuardContext } from '../../../context/global/context'
5
- import { GuardScenes } from '../../../../components/AuthingGuard/types'
6
- import { useTranslation } from 'react-i18next'
7
-
8
- export const ResetPwdFormFooter = () => {
9
- const { setValue } = useGuardContext()
10
- const { t } = useTranslation()
11
- return (
12
- <Button
13
- onClick={() => setValue('guardScenes', GuardScenes.Login)}
14
- className="authing-guard-text-btn authing-guard-form-actions"
15
- type="text"
16
- htmlType="button"
17
- >
18
- {t('login.otherAccLogin')}
19
- </Button>
20
- )
21
- }
@@ -1,86 +0,0 @@
1
- import React, { FC, useState } from 'react'
2
- import { Form, Input, Button, message } from 'antd'
3
-
4
- import { validate } from '../../../_utils'
5
- import {
6
- ResetPasswordStep1Props,
7
- ResetPwdMethods,
8
- } from '../../../../components/AuthingGuard/types'
9
- import { useGuardContext } from '../../../context/global/context'
10
- import { EmailScene } from 'authing-js-sdk'
11
- import { useTranslation } from 'react-i18next'
12
-
13
- export const ResetPasswordStep1: FC<ResetPasswordStep1Props> = ({
14
- onSuccess,
15
- }) => {
16
- const {
17
- state: { authClient, guardEvents },
18
- } = useGuardContext()
19
- const { t } = useTranslation()
20
-
21
- const [loading, setLoading] = useState(false)
22
-
23
- const onFinish = async (values: any) => {
24
- const value = values.phoneOrEmail
25
-
26
- if (validate('email', value)) {
27
- try {
28
- setLoading(true)
29
- await authClient.sendEmail(value, EmailScene.ResetPassword)
30
-
31
- guardEvents.onPwdEmailSend?.(authClient)
32
- message.success(t('login.emailSent'))
33
- onSuccess(ResetPwdMethods.Email, value)
34
- } catch (e) {
35
- guardEvents.onPwdEmailSendError?.(e, authClient)
36
- } finally {
37
- setLoading(false)
38
- }
39
- } else if (validate('phone', value)) {
40
- onSuccess(ResetPwdMethods.Phone, value)
41
- }
42
- }
43
-
44
- return (
45
- <Form
46
- onSubmitCapture={() => setLoading(true)}
47
- onFinishFailed={() => setLoading(false)}
48
- onFinish={onFinish}
49
- >
50
- <Form.Item
51
- name="phoneOrEmail"
52
- validateTrigger="onBlur"
53
- rules={[
54
- {
55
- validator: (rule, value) => {
56
- if (!value) {
57
- return Promise.reject(t('login.inputPhoneOrEmail'))
58
- }
59
- if (validate('email', value) || validate('phone', value)) {
60
- return Promise.resolve()
61
- } else {
62
- return Promise.reject(t('login.inputCorrectPhone'))
63
- }
64
- },
65
- },
66
- ]}
67
- >
68
- <Input
69
- size="large"
70
- autoComplete="tel,email"
71
- placeholder={t('login.inputPhoneOrEmail')}
72
- />
73
- </Form.Item>
74
- <Button
75
- className="authing-reset-pwd-btn"
76
- block
77
- type="primary"
78
- size="large"
79
- htmlType="submit"
80
- loading={loading}
81
- >
82
- {t('login.resetPwd')}
83
- </Button>
84
- </Form>
85
- )
86
- }
@@ -1,127 +0,0 @@
1
- import React, { FC, useState } from 'react'
2
- import { Form, Input, Button } from 'antd'
3
- import { SafetyOutlined, LockOutlined, UserOutlined } from '@ant-design/icons'
4
-
5
- import { getRequiredRules } from '../../../_utils'
6
- import { useGuardContext } from '../../../context/global/context'
7
- import { ResetPasswordStep2Props } from '../../../../components/AuthingGuard/types'
8
- import { SendPhoneCode } from '../../../../components/AuthingGuard/Forms/SendPhoneCode'
9
- import { useTranslation } from 'react-i18next'
10
-
11
- export const ResetPasswordStep2: FC<ResetPasswordStep2Props> = ({
12
- phone,
13
- onSuccess,
14
- onFail,
15
- }) => {
16
- const [rawForm] = Form.useForm()
17
- const { t } = useTranslation()
18
-
19
- const [loading, setLoading] = useState(false)
20
-
21
- const {
22
- state: { authClient, guardEvents },
23
- } = useGuardContext()
24
-
25
- const onStep2Finish = async (values: any) => {
26
- const code = values.code
27
- const password = values.password
28
-
29
- try {
30
- await authClient.resetPasswordByPhoneCode(phone, code, password)
31
- onSuccess()
32
- } catch (e) {
33
- onFail?.(e)
34
- } finally {
35
- setLoading(false)
36
- }
37
- }
38
-
39
- return (
40
- <Form
41
- form={rawForm}
42
- onFinishFailed={() => setLoading(false)}
43
- onSubmitCapture={() => setLoading(true)}
44
- onFinish={onStep2Finish}
45
- >
46
- <Form.Item
47
- name="phone"
48
- initialValue={phone}
49
- rules={getRequiredRules(t('common.phoneNotNull'))}
50
- >
51
- <Input
52
- autoComplete="tel"
53
- name="phone"
54
- readOnly
55
- size="large"
56
- placeholder={t('login.inputPhone')}
57
- prefix={<UserOutlined style={{ color: '#ddd' }} />}
58
- />
59
- </Form.Item>
60
- <Form.Item
61
- name="code"
62
- rules={getRequiredRules(t('common.inputVerifyCode')).concat({
63
- len: 4,
64
- message: t('common.inputFourVerifyCode', {
65
- length: 4,
66
- }),
67
- })}
68
- >
69
- <Input
70
- name="code"
71
- size="large"
72
- placeholder={t('common.inputFourVerifyCode', {
73
- length: 4,
74
- })}
75
- prefix={<SafetyOutlined style={{ color: '#ddd' }} />}
76
- suffix={
77
- <SendPhoneCode
78
- onError={(error) =>
79
- guardEvents.onPwdPhoneSendError?.(error, authClient)
80
- }
81
- onSend={() => guardEvents.onPwdPhoneSend?.(authClient)}
82
- phone={phone}
83
- />
84
- }
85
- />
86
- </Form.Item>
87
- <Form.Item
88
- name="password"
89
- rules={getRequiredRules(t('common.passwordNotNull'))}
90
- >
91
- <Input.Password
92
- name="password"
93
- size="large"
94
- placeholder={t('user.newPwd')}
95
- prefix={<LockOutlined style={{ color: '#ddd' }} />}
96
- />
97
- </Form.Item>
98
- <Form.Item
99
- name="repeat-password"
100
- rules={getRequiredRules(t('common.repeatPassword')).concat({
101
- validator: async (rule, value) => {
102
- if (rawForm.getFieldValue('password') !== value) {
103
- throw new Error(t('login.twoPwdNeedSame'))
104
- }
105
- },
106
- })}
107
- >
108
- <Input.Password
109
- name="repeat-password"
110
- size="large"
111
- placeholder={t('login.inputPwdAgain')}
112
- prefix={<LockOutlined style={{ color: '#ddd' }} />}
113
- />
114
- </Form.Item>
115
- <Button
116
- className="authing-reset-pwd-btn"
117
- block
118
- loading={loading}
119
- type="primary"
120
- size="large"
121
- htmlType="submit"
122
- >
123
- {t('login.resetPwd')}
124
- </Button>
125
- </Form>
126
- )
127
- }