@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,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
- }
@@ -1,141 +0,0 @@
1
- import React, { FC, useState } from 'react'
2
- import { Form, Button, Input, message } from 'antd'
3
- import { SafetyOutlined, LockOutlined } from '@ant-design/icons'
4
- import { EmailScene } from 'authing-js-sdk'
5
-
6
- import { getRequiredRules } from '../../../_utils'
7
- import { useGuardContext } from '../../../context/global/context'
8
- import { ResetPasswordStep3Props } from '../../../../components/AuthingGuard/types'
9
- import { useTranslation } from 'react-i18next'
10
-
11
- export const ResetPasswordStep3: FC<ResetPasswordStep3Props> = ({
12
- email,
13
- onSuccess = () => {},
14
- onFail,
15
- }) => {
16
- const {
17
- state: { authClient, guardEvents },
18
- } = useGuardContext()
19
- const [rawForm] = Form.useForm()
20
- const { t } = useTranslation()
21
-
22
- const [reseting, setReseting] = useState(false)
23
- const [sending, setSending] = useState(false)
24
-
25
- const onSendResetMail = async () => {
26
- setSending(true)
27
- try {
28
- await authClient.sendEmail(email, EmailScene.ResetPassword)
29
- message.success(t('login.emailSent'))
30
- guardEvents.onPwdEmailSend?.(authClient)
31
- } catch (e) {
32
- guardEvents.onPwdEmailSendError?.(e, authClient)
33
- } finally {
34
- setSending(false)
35
- }
36
- }
37
-
38
- const onStep3Finish = async (values: any) => {
39
- const code = values.code
40
- const password = values.password
41
- try {
42
- await authClient.resetPasswordByEmailCode(email, code, password)
43
- onSuccess()
44
- } catch (error) {
45
- onFail?.(error)
46
- } finally {
47
- setReseting(false)
48
- }
49
- }
50
-
51
- return (
52
- <>
53
- <p
54
- style={{
55
- marginBottom: 24,
56
- padding: '0 12px',
57
- }}
58
- >
59
- {t('login.resetEmailSent', {
60
- email: email,
61
- })}
62
- </p>
63
-
64
- <Form
65
- form={rawForm}
66
- onFinishFailed={() => setReseting(false)}
67
- onSubmitCapture={() => setReseting(true)}
68
- onFinish={onStep3Finish}
69
- >
70
- <Form.Item
71
- name="code"
72
- rules={getRequiredRules(t('common.repeatPassword')).concat({
73
- len: 4,
74
- message: t('common.inputFourVerifyCode', {
75
- length: 4,
76
- }),
77
- })}
78
- >
79
- <Input
80
- name="code"
81
- size="large"
82
- placeholder={t('login.fourVerifyCode', {
83
- length: 4,
84
- })}
85
- prefix={<SafetyOutlined style={{ color: '#ddd' }} />}
86
- />
87
- </Form.Item>
88
- <Form.Item
89
- name="password"
90
- rules={getRequiredRules(t('common.passwordNotNull'))}
91
- >
92
- <Input.Password
93
- name="password"
94
- size="large"
95
- placeholder={t('user.newPwd')}
96
- prefix={<LockOutlined style={{ color: '#ddd' }} />}
97
- />
98
- </Form.Item>
99
- <Form.Item
100
- name="repeat-password"
101
- rules={getRequiredRules(t('common.repeatPassword')).concat({
102
- validator: async (rule, value) => {
103
- if (rawForm.getFieldValue('password') !== value) {
104
- throw new Error(t('login.twoPwdNeedSame'))
105
- }
106
- },
107
- })}
108
- >
109
- <Input.Password
110
- name="repeat-password"
111
- size="large"
112
- placeholder={t('login.inputPwdAgain')}
113
- prefix={<LockOutlined style={{ color: '#ddd' }} />}
114
- />
115
- </Form.Item>
116
- <Form.Item>
117
- <Button
118
- className="authing-reset-pwd-btn"
119
- block
120
- loading={reseting}
121
- type="primary"
122
- size="large"
123
- htmlType="submit"
124
- >
125
- {t('login.resetPwd')}
126
- </Button>
127
- </Form.Item>
128
- <Button
129
- block
130
- type="primary"
131
- ghost
132
- loading={sending}
133
- size="large"
134
- onClick={onSendResetMail}
135
- >
136
- {t('login.resetPwdEmail')}
137
- </Button>
138
- </Form>
139
- </>
140
- )
141
- }
@@ -1,51 +0,0 @@
1
- import { useGuardContext } from '../../../context/global/context'
2
- import React, { FC, useEffect, useRef, useState } from 'react'
3
-
4
- import { GuardScenes } from '../../../../components/AuthingGuard/types'
5
- import { useTranslation } from 'react-i18next'
6
-
7
- const TIME = 3
8
- export const ResetPasswordStep4: FC = () => {
9
- const [countDown, setCountDown] = useState(TIME)
10
- const timerRef = useRef<any>(0)
11
- const { t } = useTranslation()
12
- const { setValue } = useGuardContext()
13
-
14
- useEffect(() => {
15
- timerRef.current = setInterval(() => {
16
- setCountDown((prev) => {
17
- return prev - 1
18
- })
19
- }, 1000)
20
-
21
- return () => clearInterval(timerRef.current)
22
- }, [])
23
-
24
- useEffect(() => {
25
- if (countDown <= 0) {
26
- clearInterval(timerRef.current)
27
-
28
- setValue('guardScenes', GuardScenes.Login)
29
- }
30
- // eslint-disable-next-line react-hooks/exhaustive-deps
31
- }, [countDown])
32
-
33
- return (
34
- <div style={{ textAlign: 'center' }}>
35
- <h3
36
- style={{
37
- fontSize: 20,
38
- fontFamily: 'PingFangSC-Medium',
39
- marginBottom: 0,
40
- }}
41
- >
42
- {t('common.pwdModifySuccess')}
43
- </h3>
44
- <p style={{ fontSize: 12 }}>
45
- {t('common.jumpAfterCount', {
46
- number: countDown,
47
- })}
48
- </p>
49
- </div>
50
- )
51
- }
@@ -1,96 +0,0 @@
1
- import React, { FC, useEffect, useState } from 'react'
2
-
3
- import { ResetPasswordStep1 } from './Step1'
4
- import { ResetPasswordStep2 } from './Step2'
5
- import { ResetPasswordStep3 } from './Step3'
6
- import { ResetPasswordStep4 } from './Step4'
7
- import { ResetPwdFormFooter } from './Footer'
8
- import { useGuardContext } from '../../../context/global/context'
9
- import { ResetPasswordFormProps } from '../../../../components/AuthingGuard/types'
10
-
11
- import './style.less'
12
- import { useTranslation } from 'react-i18next'
13
-
14
- export const ResetPasswordForm: FC<ResetPasswordFormProps> = ({
15
- onSuccess,
16
- onFail,
17
- }) => {
18
- const { setValue } = useGuardContext()
19
- const { t } = useTranslation()
20
-
21
- const [step, setStep] = useState(1)
22
- const [phone, setPhone] = useState('')
23
- const [email, setEmail] = useState('')
24
-
25
- useEffect(() => {
26
- switch (step) {
27
- case 1:
28
- setValue('guardTitle', t('common.retrievePassword'))
29
- break
30
- case 2:
31
- case 3:
32
- case 4:
33
- setValue('guardTitle', t('login.resetPwd'))
34
- break
35
- default:
36
- setValue('guardTitle', t('common.retrievePassword'))
37
- break
38
- }
39
- // eslint-disable-next-line react-hooks/exhaustive-deps
40
- }, [step])
41
-
42
- const onStep1Finish = async (type: string, value: string) => {
43
- if (type === 'phone') {
44
- setPhone(value)
45
- setStep(2)
46
- } else if (type === 'email') {
47
- setEmail(value)
48
- setStep(3)
49
- }
50
- }
51
-
52
- const onStep2OrStep3Finish = () => {
53
- setStep(4)
54
- onSuccess?.()
55
- }
56
-
57
- const onStep2OrStep3Fail = (error: any) => {
58
- onFail?.(error)
59
- }
60
-
61
- const getForm = () => {
62
- switch (step) {
63
- case 1:
64
- return (
65
- <ResetPasswordStep1 onSuccess={onStep1Finish}></ResetPasswordStep1>
66
- )
67
- case 2:
68
- return (
69
- <ResetPasswordStep2
70
- phone={phone}
71
- onFail={onStep2OrStep3Fail}
72
- onSuccess={onStep2OrStep3Finish}
73
- ></ResetPasswordStep2>
74
- )
75
- case 3:
76
- return (
77
- <ResetPasswordStep3
78
- email={email}
79
- onFail={onStep2OrStep3Fail}
80
- onSuccess={onStep2OrStep3Finish}
81
- ></ResetPasswordStep3>
82
- )
83
- case 4:
84
- return <ResetPasswordStep4></ResetPasswordStep4>
85
- default:
86
- return null
87
- }
88
- }
89
-
90
- return (
91
- <div>
92
- {getForm()}
93
- {step !== 4 && <ResetPwdFormFooter />}
94
- </div>
95
- )
96
- }
@@ -1,3 +0,0 @@
1
- .authing-reset-pwd-btn {
2
- margin-top: 24px;
3
- }
@@ -1,88 +0,0 @@
1
- import { Spin } from 'antd'
2
- import React, { FC, useState, useRef, useEffect, useMemo } from 'react'
3
- import { useTranslation } from 'react-i18next'
4
- import { LoadingOutlined } from '@ant-design/icons'
5
-
6
- const TIME = 60
7
- export interface SendCodeProps {
8
- beforeSend: () => Promise<boolean>
9
- btnRef?: React.RefObject<HTMLButtonElement>
10
- }
11
-
12
- const useSentCounter = () => {
13
- const [countDown, setCountDown] = useState(0)
14
- const timerRef = useRef<any>(0)
15
-
16
- useEffect(() => {
17
- return () => clearInterval(timerRef.current)
18
- }, [])
19
-
20
- useEffect(() => {
21
- if (countDown <= 0) {
22
- clearInterval(timerRef.current)
23
- }
24
- }, [countDown])
25
-
26
- const enabled = useMemo(() => countDown <= 0, [countDown])
27
-
28
- const send = () => {
29
- setCountDown(TIME)
30
-
31
- timerRef.current = setInterval(() => {
32
- setCountDown((prev) => {
33
- return prev - 1
34
- })
35
- }, 1000)
36
- }
37
-
38
- return {
39
- enabled,
40
- send,
41
- countDown,
42
- }
43
- }
44
-
45
- export const SendCodeBtn: FC<SendCodeProps> = ({ beforeSend, btnRef }) => {
46
- const { enabled, send, countDown } = useSentCounter()
47
- const [loading, setLoading] = useState(false)
48
- const { t } = useTranslation()
49
- const disabled = useMemo(() => {
50
- return !enabled || loading
51
- }, [enabled, loading])
52
-
53
- const onClick = async (e: React.MouseEvent<HTMLButtonElement>) => {
54
- setLoading(true)
55
- if (disabled) {
56
- return
57
- }
58
-
59
- if (!(await beforeSend())) {
60
- setLoading(false)
61
- return
62
- }
63
- setLoading(false)
64
- send()
65
- }
66
-
67
- return (
68
- <button
69
- type="button"
70
- className="authing-send-code-btn"
71
- disabled={disabled}
72
- onClick={onClick}
73
- ref={btnRef}
74
- >
75
- <Spin
76
- spinning={loading}
77
- indicator={<LoadingOutlined spin />}
78
- size="small"
79
- >
80
- {enabled
81
- ? t('common.sendVerifyCode')
82
- : t('common.retryAfterTime', {
83
- time: countDown,
84
- })}
85
- </Spin>
86
- </button>
87
- )
88
- }