@authing/react-ui-components 3.1.1 → 3.1.3-rc.2

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 (144) hide show
  1. package/lib/index.d.ts +2573 -201
  2. package/lib/index.min.css +2 -1
  3. package/lib/index.min.js +1 -1
  4. package/lib/index.min.js.LICENSE.txt +42 -0
  5. package/lib/static/media/loading.4a67a5f3.svg +29 -0
  6. package/package.json +54 -18
  7. package/.eslintignore +0 -6
  8. package/.eslintrc.js +0 -7
  9. package/.prettierrc +0 -5
  10. package/.vscode/settings.json +0 -31
  11. package/LICENSE +0 -21
  12. package/config/antdReplacer.js +0 -51
  13. package/config/env.js +0 -106
  14. package/config/getHttpsConfig.js +0 -66
  15. package/config/jest/cssTransform.js +0 -14
  16. package/config/jest/fileTransform.js +0 -40
  17. package/config/modules.js +0 -134
  18. package/config/paths.js +0 -71
  19. package/config/pnpTs.js +0 -35
  20. package/config/webpack.config.js +0 -857
  21. package/config/webpackDevServer.config.js +0 -130
  22. package/public/favicon.ico +0 -0
  23. package/public/index.html +0 -43
  24. package/public/logo192.png +0 -0
  25. package/public/logo512.png +0 -0
  26. package/public/manifest.json +0 -25
  27. package/public/robots.txt +0 -3
  28. package/scripts/build.js +0 -212
  29. package/scripts/lib.js +0 -200
  30. package/scripts/start.js +0 -166
  31. package/scripts/test.js +0 -53
  32. package/src/common/AuthingDropdown/index.tsx +0 -52
  33. package/src/common/AuthingDropdown/style.less +0 -43
  34. package/src/common/AuthingTabs/index.tsx +0 -98
  35. package/src/common/AuthingTabs/style.less +0 -135
  36. package/src/common/CopyAbleText/index.tsx +0 -54
  37. package/src/common/CopyAbleText/style.less +0 -13
  38. package/src/common/VerifyCodeInput/index.tsx +0 -76
  39. package/src/common/VerifyCodeInput/style.less +0 -24
  40. package/src/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  41. package/src/components/AuthingGuard/AppMFALayout/style.less +0 -12
  42. package/src/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  43. package/src/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  44. package/src/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  45. package/src/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  46. package/src/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  47. package/src/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  48. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -86
  49. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  50. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  51. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  52. package/src/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  53. package/src/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  54. package/src/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -161
  55. package/src/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  56. package/src/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  57. package/src/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  58. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  59. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  60. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  61. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  62. package/src/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  63. package/src/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  64. package/src/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  65. package/src/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  66. package/src/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  67. package/src/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -61
  68. package/src/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  69. package/src/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  70. package/src/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  71. package/src/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  72. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  73. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  74. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  75. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  76. package/src/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  77. package/src/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  78. package/src/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  79. package/src/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  80. package/src/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  81. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  82. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  83. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  84. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  85. package/src/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  86. package/src/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  87. package/src/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  88. package/src/components/AuthingGuard/Forms/index.ts +0 -13
  89. package/src/components/AuthingGuard/GuardLayout/index.tsx +0 -488
  90. package/src/components/AuthingGuard/GuardLayout/style.less +0 -111
  91. package/src/components/AuthingGuard/Header/index.tsx +0 -28
  92. package/src/components/AuthingGuard/Header/style.less +0 -64
  93. package/src/components/AuthingGuard/IconFont/iconfont.js +0 -74
  94. package/src/components/AuthingGuard/IconFont/index.tsx +0 -19
  95. package/src/components/AuthingGuard/IconFont/style.less +0 -6
  96. package/src/components/AuthingGuard/IconFont/svg.js +0 -2
  97. package/src/components/AuthingGuard/LoginLayout/index.tsx +0 -205
  98. package/src/components/AuthingGuard/LoginLayout/style.less +0 -0
  99. package/src/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  100. package/src/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  101. package/src/components/AuthingGuard/MfaLayout/style.less +0 -3
  102. package/src/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  103. package/src/components/AuthingGuard/RegisterLayout/style.less +0 -0
  104. package/src/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  105. package/src/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  106. package/src/components/AuthingGuard/api/appConfig.ts +0 -154
  107. package/src/components/AuthingGuard/api/http.ts +0 -88
  108. package/src/components/AuthingGuard/api/index.ts +0 -3
  109. package/src/components/AuthingGuard/api/sso.ts +0 -29
  110. package/src/components/AuthingGuard/api/userPoolConfig.ts +0 -112
  111. package/src/components/AuthingGuard/constants.ts +0 -107
  112. package/src/components/AuthingGuard/hooks/index.tsx +0 -70
  113. package/src/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  114. package/src/components/AuthingGuard/index.tsx +0 -134
  115. package/src/components/AuthingGuard/locales/en/common.json +0 -185
  116. package/src/components/AuthingGuard/locales/en/index.ts +0 -6
  117. package/src/components/AuthingGuard/locales/en/login.json +0 -94
  118. package/src/components/AuthingGuard/locales/en/map.json +0 -4
  119. package/src/components/AuthingGuard/locales/en/user.json +0 -81
  120. package/src/components/AuthingGuard/locales/index.ts +0 -45
  121. package/src/components/AuthingGuard/locales/zh/common.json +0 -185
  122. package/src/components/AuthingGuard/locales/zh/index.ts +0 -6
  123. package/src/components/AuthingGuard/locales/zh/login.json +0 -94
  124. package/src/components/AuthingGuard/locales/zh/map.json +0 -4
  125. package/src/components/AuthingGuard/locales/zh/user.json +0 -81
  126. package/src/components/AuthingGuard/style.less +0 -104
  127. package/src/components/AuthingGuard/types/Forms.ts +0 -95
  128. package/src/components/AuthingGuard/types/GuardConfig.ts +0 -424
  129. package/src/components/AuthingGuard/types/GuardState.ts +0 -7
  130. package/src/components/AuthingGuard/types/Locales.ts +0 -12
  131. package/src/components/AuthingGuard/types/index.ts +0 -4
  132. package/src/components/index.ts +0 -7
  133. package/src/context/base.tsx +0 -28
  134. package/src/context/global/context.tsx +0 -39
  135. package/src/context/global/reducer.tsx +0 -56
  136. package/src/index.tsx +0 -142
  137. package/src/logo.svg +0 -7
  138. package/src/react-app-env.d.ts +0 -71
  139. package/src/reportWebVitals.ts +0 -15
  140. package/src/setupTests.ts +0 -5
  141. package/src/utils/clipboard.ts +0 -27
  142. package/src/utils/index.ts +0 -180
  143. package/src/utils/popupCenter.ts +0 -48
  144. package/tsconfig.json +0 -24
@@ -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,61 +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
- idpId,
18
- }) => {
19
- const {
20
- state: { authClient, config },
21
- } = useGuardContext()
22
-
23
- const timerRef = useRef<any>()
24
-
25
- const client = useMemo(() => {
26
- return {
27
- [LoginMethods.AppQr]: authClient.qrcode,
28
- [LoginMethods.WxMinQr]: authClient.wxqrcode,
29
- [LoginMethods.WechatMpQrcode]: authClient.wechatmpqrcode,
30
- }[type]
31
- }, [type, authClient])
32
-
33
- useEffect(() => {
34
- client.startScanning('authingGuardQrcode', {
35
- extIdpConnId: idpId,
36
- autoExchangeUserInfo: true,
37
- ...config.qrCodeScanOptions,
38
- onStart(timer) {
39
- timerRef.current = timer
40
- },
41
- onSuccess(user) {
42
- onSuccess && onSuccess(user as User)
43
- },
44
- onError: (message) => {
45
- config.qrCodeScanOptions?.onError?.(message)
46
-
47
- onFail && onFail(`${message}`)
48
- },
49
- })
50
- return () => clearInterval(timerRef.current)
51
- }, [client, config.qrCodeScanOptions, idpId, onFail, onSuccess])
52
-
53
- return (
54
- <div className="authing-guard-qr-form">
55
- <div className="authing-guard-qr-loading">
56
- <Spin size="large" />
57
- </div>
58
- <div id="authingGuardQrcode"></div>
59
- </div>
60
- )
61
- }
@@ -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
- }