@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,166 +0,0 @@
1
- import { Input, Form, message } from 'antd'
2
- import { FormInstance } from 'antd/lib/form'
3
- import { UserOutlined, LockOutlined } from '@ant-design/icons'
4
- import React, { forwardRef, useImperativeHandle, useState } from 'react'
5
-
6
- import { getRequiredRules } from '../../../_utils'
7
- import { useGuardContext } from '../../../context/global/context'
8
- import { NEED_CAPTCHA } from '../../../../components/AuthingGuard/constants'
9
- import {
10
- LoginMethods,
11
- PasswordLoginFormProps,
12
- } from '../../../../components/AuthingGuard/types'
13
- import { LoginFormFooter } from '../../../../components/AuthingGuard/Forms/LoginFormFooter'
14
- import { useTranslation } from 'react-i18next'
15
-
16
- export const LdapLoginForm = forwardRef<FormInstance, PasswordLoginFormProps>(
17
- ({ onSuccess, onValidateFail, onFail }, ref) => {
18
- const { t } = useTranslation()
19
-
20
- const { state } = useGuardContext()
21
- const { config, authClient, realHost, guardEvents } = state
22
- const autoRegister = config.autoRegister
23
-
24
- const [rawForm] = Form.useForm()
25
-
26
- const [needCaptcha, setNeedCaptcha] = useState(false)
27
- const [verifyCodeUrl, setVerifyCodeUrl] = useState<string | null>(null)
28
- const [loading, setLoading] = useState(false)
29
-
30
- const captchaUrl = `${realHost}/api/v2/security/captcha`
31
- const getCaptchaUrl = () => `${captchaUrl}?r=${+new Date()}`
32
-
33
- const onFinishFailed = (errorInfo: any) => {
34
- setLoading(false)
35
- onValidateFail && onValidateFail(errorInfo)
36
- }
37
-
38
- const onFinish = async (values: any) => {
39
- if (guardEvents.onBeforeLogin) {
40
- try {
41
- const canLogin = await guardEvents.onBeforeLogin(
42
- {
43
- type: LoginMethods.LDAP,
44
- data: {
45
- identity: values.identity,
46
- password: values.password,
47
- captchaCode: values.captchaCode,
48
- },
49
- },
50
- authClient
51
- )
52
-
53
- if (!canLogin) {
54
- setLoading(false)
55
- return
56
- }
57
- } catch (e) {
58
- if (typeof e === 'string') {
59
- message.error(e)
60
- } else {
61
- message.error(e.message)
62
- }
63
- setLoading(false)
64
- return
65
- }
66
- }
67
-
68
- try {
69
- const identity = values.identity && values.identity.trim()
70
- const password = values.password && values.password.trim()
71
- const captchaCode = values.captchaCode && values.captchaCode.trim()
72
-
73
- const user = await authClient.loginByLdap(identity, password, {
74
- autoRegister,
75
- captchaCode,
76
- })
77
- onSuccess && onSuccess(user)
78
- } catch (error) {
79
- if (typeof error.message === 'string') {
80
- // js sdk httpclient 的报错,这里只有一种情况就是用户开启了 mfa 的报错
81
- try {
82
- const errorData = JSON.parse(error.message)
83
- onFail && onFail(errorData)
84
- return
85
- } catch (_) {}
86
- }
87
-
88
- if (error.code === NEED_CAPTCHA && verifyCodeUrl === null) {
89
- setNeedCaptcha(true)
90
- setVerifyCodeUrl(getCaptchaUrl())
91
- }
92
-
93
- onFail && onFail(error)
94
- } finally {
95
- setLoading(false)
96
- }
97
- }
98
-
99
- useImperativeHandle(ref, () => rawForm)
100
-
101
- const formItems = [
102
- {
103
- component: (
104
- <Input
105
- autoComplete="ldap,username"
106
- size="large"
107
- placeholder={t('login.inputLdapUsername')}
108
- prefix={<UserOutlined style={{ color: '#ddd' }} />}
109
- />
110
- ),
111
- name: 'identity',
112
- rules: getRequiredRules(t('common.LDAPAccountNotNull')),
113
- },
114
- {
115
- component: (
116
- <Input.Password
117
- size="large"
118
- placeholder={t('login.inputLdapPwd')}
119
- prefix={<LockOutlined style={{ color: '#ddd' }} />}
120
- />
121
- ),
122
- name: 'password',
123
- rules: getRequiredRules(t('common.passwordNotNull')),
124
- },
125
- {
126
- component: (
127
- <Input
128
- size="large"
129
- placeholder={t('login.inputCaptchaCode')}
130
- addonAfter={
131
- <img
132
- src={verifyCodeUrl ?? ''}
133
- alt={t('login.captchaCode')}
134
- style={{ height: '2em', cursor: 'pointer' }}
135
- onClick={() => setVerifyCodeUrl(getCaptchaUrl())}
136
- />
137
- }
138
- />
139
- ),
140
- name: 'captchaCode',
141
- rules: getRequiredRules(t('common.captchaCodeNotNull')),
142
- hide: !needCaptcha,
143
- },
144
- ]
145
-
146
- return (
147
- <Form
148
- form={rawForm}
149
- onSubmitCapture={() => setLoading(true)}
150
- onFinishFailed={onFinishFailed}
151
- onFinish={onFinish}
152
- >
153
- {formItems.map(
154
- (item) =>
155
- !item.hide && (
156
- <Form.Item key={item.name} name={item.name} rules={item.rules}>
157
- {item.component}
158
- </Form.Item>
159
- )
160
- )}
161
-
162
- <LoginFormFooter loading={loading}></LoginFormFooter>
163
- </Form>
164
- )
165
- }
166
- )
@@ -1,76 +0,0 @@
1
- import { Button, Divider } from 'antd'
2
- import React, { FC } from 'react'
3
- import { useGuardContext } from '../../../context/global/context'
4
- import { GuardScenes } from '../../../../components/AuthingGuard/types'
5
- import './style.less'
6
- import { useTranslation } from 'react-i18next'
7
-
8
- export interface LoginFormFooterProps {
9
- loading: boolean
10
- needRestPwd?: boolean
11
- needRegister?: boolean
12
- }
13
-
14
- export const LoginFormFooter: FC<LoginFormFooterProps> = ({
15
- loading,
16
- needRestPwd = false,
17
- needRegister = false,
18
- }) => {
19
- const { t } = useTranslation()
20
-
21
- const {
22
- setValue,
23
- state: { config },
24
- } = useGuardContext()
25
-
26
- return (
27
- <>
28
- <Button
29
- htmlType="submit"
30
- className="authing-guard-form-submit-btn"
31
- size="large"
32
- type="primary"
33
- loading={loading}
34
- block
35
- >
36
- {loading
37
- ? t(
38
- `map.${config.text?.loginBtn?.loading}`,
39
- config.text?.loginBtn?.loading
40
- )
41
- : t(
42
- `map.${config.text?.loginBtn?.normal}`,
43
- config.text?.loginBtn?.normal
44
- )}
45
- </Button>
46
-
47
- <div className="authing-guard-form-actions">
48
- {needRestPwd && !config.disableResetPwd && (
49
- <Button
50
- onClick={() => setValue('guardScenes', GuardScenes.RestPassword)}
51
- className="authing-guard-text-btn"
52
- type="text"
53
- >
54
- {t('common.hasForgotPwd')}
55
- </Button>
56
- )}
57
- {needRestPwd &&
58
- needRegister &&
59
- !config.disableResetPwd &&
60
- !config.disableRegister && <Divider type="vertical" />}
61
- {needRegister && !config.disableRegister && (
62
- <div className="authing-guard-tip-btn-comb">
63
- <span className="authing-guard-tip">{t('common.noAccYet')}</span>
64
- <Button
65
- onClick={() => setValue('guardScenes', GuardScenes.Register)}
66
- className="authing-guard-text-btn authing-guard-to-register-btn"
67
- type="text"
68
- >
69
- {t('common.registerImmediate')}
70
- </Button>
71
- </div>
72
- )}
73
- </div>
74
- </>
75
- )
76
- }
@@ -1,6 +0,0 @@
1
- @media only screen and (max-width: 719px) {
2
- .authing-guard-form-submit-btn {
3
- margin-top: 56px;
4
- font-size: 14px;
5
- }
6
- }
@@ -1,86 +0,0 @@
1
- import { Input, Form, Button } from 'antd'
2
- import React, { FC, useState } from 'react'
3
- import { LockOutlined } from '@ant-design/icons'
4
- import { getRequiredRules } from '../../../_utils'
5
- import { useGuardContext } from '../../../context/global/context'
6
- import { User } from 'authing-js-sdk'
7
- import { useTranslation } from 'react-i18next'
8
-
9
- export const MfaResetStep1: FC<{
10
- mfaToken: string
11
- onSuccess: (
12
- user: User & {
13
- recoveryCode: string
14
- }
15
- ) => void
16
- goVerify: () => void
17
- onFail?: (error: any) => void
18
- }> = ({ mfaToken, onSuccess, goVerify, onFail }) => {
19
- const [loading, setLoading] = useState(false)
20
- const { t } = useTranslation()
21
-
22
- const {
23
- state: { authClient },
24
- } = useGuardContext()
25
-
26
- const onFinish = async (values: any) => {
27
- try {
28
- const user = await authClient.mfa.verifyTotpRecoveryCode({
29
- recoveryCode: values.recoverCode,
30
- mfaToken,
31
- })
32
- onSuccess(
33
- user as User & {
34
- recoveryCode: string
35
- }
36
- )
37
- } catch (e) {
38
- onFail?.(e)
39
- } finally {
40
- setLoading(false)
41
- }
42
- }
43
-
44
- return (
45
- <Form
46
- onSubmitCapture={() => setLoading(true)}
47
- onFinishFailed={() => setLoading(false)}
48
- onFinish={onFinish}
49
- >
50
- <Form.Item
51
- rules={getRequiredRules(t('common.recoverCodeNotNull'))}
52
- name="recoverCode"
53
- >
54
- <Input
55
- prefix={<LockOutlined style={{ color: '#ddd' }} />}
56
- placeholder={t('login.inputRecoverCode')}
57
- size="large"
58
- ></Input>
59
- </Form.Item>
60
-
61
- <Button
62
- className="authing-guard-mfa-confirm-btn"
63
- loading={loading}
64
- htmlType="submit"
65
- block
66
- type="primary"
67
- size="large"
68
- >
69
- {t('common.sure')}
70
- </Button>
71
-
72
- <div className="authing-guard-form-actions">
73
- <div className="authing-guard-tip-btn-comb">
74
- <Button
75
- htmlType="button"
76
- onClick={goVerify}
77
- className="authing-guard-text-btn"
78
- type="text"
79
- >
80
- {t('login.findedSafetyCode')}
81
- </Button>
82
- </div>
83
- </div>
84
- </Form>
85
- )
86
- }
@@ -1,53 +0,0 @@
1
- import React, { FC } from 'react'
2
-
3
- import { Button, Checkbox, Form } from 'antd'
4
- import { CopyAbleText } from '../../../CopyAbleText'
5
- import { useTranslation } from 'react-i18next'
6
-
7
- export interface MfaResetStep2Props {
8
- recoverCode: string
9
- onFinish: () => void
10
- }
11
-
12
- export const MfaResetStep2: FC<MfaResetStep2Props> = ({
13
- recoverCode,
14
- onFinish,
15
- }) => {
16
- const { t } = useTranslation()
17
- return (
18
- <Form onFinish={onFinish}>
19
- <CopyAbleText className="authing-guard-secret-block">
20
- {recoverCode}
21
- </CopyAbleText>
22
- <Form.Item
23
- valuePropName="checked"
24
- rules={[
25
- {
26
- validateTrigger: [],
27
- validator(r, v) {
28
- return new Promise((resolve, reject) => {
29
- if (!v) {
30
- reject(t('login.confirmSavedCode'))
31
- }
32
- resolve(true)
33
- })
34
- },
35
- },
36
- ]}
37
- name="MfaCopyRecoverCode"
38
- >
39
- <Checkbox>{t('login.rememberedSecret')}</Checkbox>
40
- </Form.Item>
41
-
42
- <Button
43
- className="authing-guard-mfa-confirm-btn"
44
- htmlType="submit"
45
- block
46
- type="primary"
47
- size="large"
48
- >
49
- {t('common.sure')}
50
- </Button>
51
- </Form>
52
- )
53
- }
@@ -1,65 +0,0 @@
1
- import { User } from 'authing-js-sdk'
2
- import React, { FC, useState } from 'react'
3
-
4
- import { MfaResetStep1 } from './Step1'
5
- import { MfaResetStep2 } from './Step2'
6
- import { useGuardContext } from '../../../context/global/context'
7
- import { MfaResetForm } from '../../../../components/AuthingGuard/types'
8
-
9
- import './style.less'
10
- import { useTranslation } from 'react-i18next'
11
-
12
- export const MfaResetCodeForm: FC<MfaResetForm> = ({
13
- goVerify,
14
- onSuccess,
15
- onFail,
16
- }) => {
17
- const { t } = useTranslation()
18
-
19
- const {
20
- state: {
21
- mfaData: { mfaToken },
22
- },
23
- } = useGuardContext()
24
-
25
- const [step, setStep] = useState(1)
26
- const [user, setUser] = useState<User | null>(null)
27
- const [recoverCode, setRecoverCode] = useState('')
28
-
29
- const onReset = (
30
- user: User & {
31
- recoveryCode: string
32
- }
33
- ) => {
34
- setStep(2)
35
- setUser(user)
36
- setRecoverCode(user.recoveryCode)
37
- }
38
-
39
- const stepMap: Record<number, JSX.Element | undefined> = {
40
- 1: (
41
- <MfaResetStep1
42
- onFail={onFail}
43
- goVerify={goVerify}
44
- onSuccess={onReset}
45
- mfaToken={mfaToken}
46
- />
47
- ),
48
- 2: (
49
- <MfaResetStep2
50
- onFinish={() => onSuccess?.(user!)}
51
- recoverCode={recoverCode}
52
- />
53
- ),
54
- }
55
-
56
- return (
57
- <>
58
- <h2 className="authing-guard-mfa-reset-title">
59
- {t('common.useRecoverCode')}
60
- </h2>
61
- <p className="authing-guard-mfa-reset-tips">{t('login.mfaAfterReset')}</p>
62
- {stepMap[step]}
63
- </>
64
- )
65
- }
@@ -1,20 +0,0 @@
1
- .authing-guard-secret-block {
2
- border: 1px solid #ddd;
3
- justify-content: center;
4
- border-radius: 2px;
5
- padding: 12px 0;
6
- text-align: center;
7
- }
8
-
9
- .authing-guard-mfa-reset-title {
10
- color: #181818;
11
- font-size: 18px;
12
- font-weight: 600;
13
- text-align: center;
14
- margin: 0;
15
- }
16
-
17
- .authing-guard-mfa-reset-tips {
18
- margin: 38px 0;
19
- text-align: center;
20
- }
@@ -1,105 +0,0 @@
1
- import { User } from 'authing-js-sdk'
2
- import React, { FC, useState } from 'react'
3
- import { Button, Form } from 'antd'
4
-
5
- import { VerifyCodeInput } from '../../../VerifyCodeInput'
6
- import { useGuardContext } from '../../../context/global/context'
7
- import { MfaVerifyForm } from '../../../../components/AuthingGuard/types'
8
-
9
- import './style.less'
10
- import { useTranslation } from 'react-i18next'
11
-
12
- const CODE_LEN = 6
13
-
14
- export const MFAVerifyForm: FC<MfaVerifyForm> = ({
15
- onSuccess,
16
- onFail,
17
- goReset,
18
- }) => {
19
- const {
20
- state: {
21
- authClient,
22
- mfaData: { mfaToken },
23
- },
24
- } = useGuardContext()
25
-
26
- const { t } = useTranslation()
27
-
28
- const [rawForm] = Form.useForm()
29
-
30
- const [MfaCode, setMFACode] = useState(new Array(CODE_LEN).fill(''))
31
- const [loading, setLoading] = useState(false)
32
-
33
- const onFinish = async (values: any) => {
34
- try {
35
- const user: User = await authClient.mfa.verifyTotpMfa({
36
- mfaToken,
37
- totp: MfaCode.join(''),
38
- })
39
- onSuccess && onSuccess(user)
40
- } catch (e) {
41
- onFail?.(e)
42
- } finally {
43
- setLoading(false)
44
- }
45
- }
46
-
47
- return (
48
- <>
49
- <h3 className="authing-guard-mfa-title">
50
- {t('login.accPwdLoginVerify')}
51
- </h3>
52
- <p className="authing-guard-mfa-tips">{t('login.inputSixCode')}</p>
53
- <Form
54
- form={rawForm}
55
- onSubmitCapture={() => setLoading(true)}
56
- onFinish={onFinish}
57
- onFinishFailed={() => setLoading(false)}
58
- >
59
- <Form.Item
60
- name="mfaCode"
61
- rules={[
62
- {
63
- validateTrigger: [],
64
- validator() {
65
- if (MfaCode.some((item) => !item)) {
66
- return Promise.reject(t('login.inputFullMfaCode'))
67
- }
68
- return Promise.resolve()
69
- },
70
- },
71
- ]}
72
- >
73
- <VerifyCodeInput verifyCode={MfaCode} setVerifyCode={setMFACode} />
74
- </Form.Item>
75
-
76
- <Button
77
- className="authing-guard-mfa-confirm-btn"
78
- loading={loading}
79
- block
80
- htmlType="submit"
81
- type="primary"
82
- size="large"
83
- >
84
- {t('common.sure')}
85
- </Button>
86
-
87
- <div className="authing-guard-form-actions">
88
- <div className="authing-guard-tip-btn-comb">
89
- <span className="authing-guard-tip">
90
- {t('common.hasLooseSaftyCode')}
91
- </span>
92
- <Button
93
- htmlType="button"
94
- onClick={goReset}
95
- className="authing-guard-text-btn"
96
- type="text"
97
- >
98
- {t('common.useRecoverCode')}
99
- </Button>
100
- </div>
101
- </div>
102
- </Form>
103
- </>
104
- )
105
- }
@@ -1,12 +0,0 @@
1
- .authing-guard-mfa-title {
2
- color: #181818;
3
- font-size: 18px;
4
- font-weight: 600;
5
- text-align: center;
6
- margin: 0;
7
- }
8
-
9
- .authing-guard-mfa-tips {
10
- margin: 38px 0;
11
- text-align: center;
12
- }