@authing/react-ui-components 3.0.2-Beta.0 → 3.0.2-beta.10

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 (262) hide show
  1. package/lib/index.d.ts +466 -45
  2. package/lib/index.min.css +2 -2
  3. package/lib/index.min.js +1 -1
  4. package/package.json +26 -10
  5. package/.eslintignore +0 -6
  6. package/.eslintrc.js +0 -7
  7. package/.prettierrc +0 -5
  8. package/.vscode/settings.json +0 -31
  9. package/build/asset-manifest.json +0 -26
  10. package/build/favicon.ico +0 -0
  11. package/build/index.html +0 -1
  12. package/build/logo192.png +0 -0
  13. package/build/logo512.png +0 -0
  14. package/build/manifest.json +0 -25
  15. package/build/robots.txt +0 -3
  16. package/build/static/css/2.9512539b.chunk.css +0 -3
  17. package/build/static/css/2.9512539b.chunk.css.map +0 -1
  18. package/build/static/css/main.0ff9e24a.chunk.css +0 -2
  19. package/build/static/css/main.0ff9e24a.chunk.css.map +0 -1
  20. package/build/static/js/2.1105ecfb.chunk.js +0 -3
  21. package/build/static/js/2.1105ecfb.chunk.js.LICENSE.txt +0 -102
  22. package/build/static/js/2.1105ecfb.chunk.js.map +0 -1
  23. package/build/static/js/3.fd17f196.chunk.js +0 -2
  24. package/build/static/js/3.fd17f196.chunk.js.map +0 -1
  25. package/build/static/js/main.a47645ff.chunk.js +0 -2
  26. package/build/static/js/main.a47645ff.chunk.js.map +0 -1
  27. package/build/static/js/runtime-main.ef138021.js +0 -2
  28. package/build/static/js/runtime-main.ef138021.js.map +0 -1
  29. package/build/static/media/loading.4a67a5f3.svg +0 -29
  30. package/components/AuthingDropdown/index.tsx +0 -52
  31. package/components/AuthingDropdown/style.less +0 -43
  32. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  33. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  34. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  35. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  36. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  37. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  38. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  39. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  40. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  41. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  42. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  43. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  44. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  45. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  46. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  47. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  48. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  49. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  50. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  51. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  52. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  53. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  54. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  55. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  56. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  57. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  58. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  59. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  60. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  61. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  62. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  63. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  64. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  65. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  66. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  67. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  68. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  69. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  70. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  71. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  72. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  73. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  74. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  75. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  76. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  77. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  78. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  79. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  80. package/components/AuthingGuard/Forms/index.ts +0 -13
  81. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  82. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  83. package/components/AuthingGuard/Header/index.tsx +0 -25
  84. package/components/AuthingGuard/Header/style.less +0 -52
  85. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  86. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  87. package/components/AuthingGuard/IconFont/style.less +0 -6
  88. package/components/AuthingGuard/IconFont/svg.js +0 -2
  89. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  90. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  91. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  92. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  93. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  94. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  95. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  96. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  97. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  98. package/components/AuthingGuard/api/appConfig.ts +0 -146
  99. package/components/AuthingGuard/api/index.ts +0 -3
  100. package/components/AuthingGuard/api/sso.ts +0 -29
  101. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  102. package/components/AuthingGuard/constants.ts +0 -107
  103. package/components/AuthingGuard/hooks/index.tsx +0 -70
  104. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  105. package/components/AuthingGuard/index.tsx +0 -126
  106. package/components/AuthingGuard/style.less +0 -103
  107. package/components/AuthingGuard/types/Forms.ts +0 -94
  108. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  109. package/components/AuthingGuard/types/GuardState.ts +0 -7
  110. package/components/AuthingGuard/types/Locales.ts +0 -12
  111. package/components/AuthingGuard/types/index.ts +0 -4
  112. package/components/AuthingTabs/index.tsx +0 -98
  113. package/components/AuthingTabs/style.less +0 -135
  114. package/components/BindTotp/core/bindSuccess.tsx +0 -73
  115. package/components/BindTotp/core/securityCode.tsx +0 -108
  116. package/components/BindTotp/index.tsx +0 -134
  117. package/components/BindTotp/interface.ts +0 -30
  118. package/components/BindTotp/styles.less +0 -57
  119. package/components/ChangeLanguage/index.tsx +0 -35
  120. package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
  121. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  122. package/components/ChangePassword/index.tsx +0 -59
  123. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  124. package/components/CompleteInfo/index.tsx +0 -45
  125. package/components/CompleteInfo/interface.ts +0 -40
  126. package/components/CompleteInfo/styles.less +0 -7
  127. package/components/CopyAbleText/index.tsx +0 -54
  128. package/components/CopyAbleText/style.less +0 -13
  129. package/components/DownloadAuthenticator/index.tsx +0 -97
  130. package/components/DownloadAuthenticator/interface.ts +0 -22
  131. package/components/DownloadAuthenticator/styles.less +0 -52
  132. package/components/Error/index.tsx +0 -21
  133. package/components/Error/interface.ts +0 -9
  134. package/components/Error/styles.less +0 -12
  135. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  136. package/components/ForgetPassword/index.tsx +0 -78
  137. package/components/ForgetPassword/interface.ts +0 -32
  138. package/components/Guard/Guard.tsx +0 -255
  139. package/components/Guard/authClient.ts +0 -46
  140. package/components/Guard/config.ts +0 -19
  141. package/components/Guard/event.ts +0 -52
  142. package/components/Guard/index.tsx +0 -4
  143. package/components/Guard/module.ts +0 -20
  144. package/components/Guard/stateMachine.ts +0 -133
  145. package/components/Guard/styles.less +0 -461
  146. package/components/IconFont/iconfont.js +0 -74
  147. package/components/IconFont/index.tsx +0 -16
  148. package/components/IconFont/style.less +0 -6
  149. package/components/IconFont/svg.js +0 -2
  150. package/components/ImagePro/index.tsx +0 -53
  151. package/components/ImagePro/styles.less +0 -40
  152. package/components/InputNumber/index.tsx +0 -33
  153. package/components/Login/codemap.ts +0 -47
  154. package/components/Login/core/withAD.tsx +0 -9
  155. package/components/Login/core/withAppQrcode.tsx +0 -49
  156. package/components/Login/core/withLDAP.tsx +0 -146
  157. package/components/Login/core/withPassword/FormItemAccount.tsx +0 -42
  158. package/components/Login/core/withPassword/GraphicVerifyCode.tsx +0 -31
  159. package/components/Login/core/withPassword/InputAccount.tsx +0 -64
  160. package/components/Login/core/withPassword/index.tsx +0 -173
  161. package/components/Login/core/withPhonecode.tsx +0 -122
  162. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  163. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  164. package/components/Login/index.tsx +0 -373
  165. package/components/Login/props.ts +0 -74
  166. package/components/Login/socialLogin/index.tsx +0 -407
  167. package/components/Login/socialLogin/style.less +0 -69
  168. package/components/Login/styles.less +0 -53
  169. package/components/MFA/VerifyCodeInput/VerifyCodeFormItem.tsx +0 -41
  170. package/components/MFA/VerifyCodeInput/index.tsx +0 -145
  171. package/components/MFA/VerifyCodeInput/style.less +0 -35
  172. package/components/MFA/codemap.ts +0 -24
  173. package/components/MFA/core/email.tsx +0 -203
  174. package/components/MFA/core/face.tsx +0 -297
  175. package/components/MFA/core/face_deps.tsx +0 -37
  176. package/components/MFA/core/sms.tsx +0 -204
  177. package/components/MFA/core/totp.tsx +0 -122
  178. package/components/MFA/index.tsx +0 -143
  179. package/components/MFA/mfaMethods/index.tsx +0 -88
  180. package/components/MFA/mfaMethods/style.less +0 -39
  181. package/components/MFA/props.ts +0 -51
  182. package/components/MFA/styles.less +0 -100
  183. package/components/NeedHelpView/core/describeQuestions.tsx +0 -245
  184. package/components/NeedHelpView/index.tsx +0 -47
  185. package/components/RecoveryCode/core/useCode.tsx +0 -71
  186. package/components/RecoveryCode/index.tsx +0 -27
  187. package/components/RecoveryCode/interface.ts +0 -31
  188. package/components/RecoveryCode/style.less +0 -13
  189. package/components/Register/codemap.ts +0 -12
  190. package/components/Register/components/Agreements/index.tsx +0 -81
  191. package/components/Register/components/Agreements/style.less +0 -44
  192. package/components/Register/core/WithEmail.tsx +0 -239
  193. package/components/Register/core/WithPhone.tsx +0 -184
  194. package/components/Register/index.tsx +0 -138
  195. package/components/Register/props.ts +0 -50
  196. package/components/SendCode/SendCodeBtn.tsx +0 -96
  197. package/components/SendCode/index.tsx +0 -94
  198. package/components/SendCode/style.less +0 -31
  199. package/components/ShieldSpin/index.tsx +0 -27
  200. package/components/ShieldSpin/loading.svg +0 -29
  201. package/components/SubmitButton/index.tsx +0 -50
  202. package/components/SubmitSuccess/index.tsx +0 -66
  203. package/components/SubmitSuccess/interface.ts +0 -17
  204. package/components/Type/index.ts +0 -52
  205. package/components/ValidatorRules/EmailFormItem.tsx +0 -95
  206. package/components/ValidatorRules/PhoneFormItem.tsx +0 -100
  207. package/components/ValidatorRules/index.ts +0 -14
  208. package/components/VerifyCodeInput/index.tsx +0 -76
  209. package/components/VerifyCodeInput/style.less +0 -24
  210. package/components/_utils/GuardErrorCode.ts +0 -9
  211. package/components/_utils/clipboard.ts +0 -27
  212. package/components/_utils/config.ts +0 -118
  213. package/components/_utils/guradHttp.ts +0 -97
  214. package/components/_utils/hooks/index.ts +0 -64
  215. package/components/_utils/http.ts +0 -85
  216. package/components/_utils/index.ts +0 -322
  217. package/components/_utils/locales/en/common.json +0 -227
  218. package/components/_utils/locales/en/index.ts +0 -6
  219. package/components/_utils/locales/en/login.json +0 -96
  220. package/components/_utils/locales/en/map.json +0 -4
  221. package/components/_utils/locales/en/user.json +0 -82
  222. package/components/_utils/locales/index.ts +0 -45
  223. package/components/_utils/locales/zh/common.json +0 -227
  224. package/components/_utils/locales/zh/index.ts +0 -6
  225. package/components/_utils/locales/zh/login.json +0 -96
  226. package/components/_utils/locales/zh/map.json +0 -4
  227. package/components/_utils/locales/zh/user.json +0 -82
  228. package/components/_utils/popupCenter.ts +0 -48
  229. package/components/assets/images/error.png +0 -0
  230. package/components/context/base.tsx +0 -28
  231. package/components/context/global/context.tsx +0 -39
  232. package/components/context/global/reducer.tsx +0 -56
  233. package/components/context/module/context.tsx +0 -23
  234. package/components/index.ts +0 -12
  235. package/config/antdReplacer.js +0 -51
  236. package/config/env.js +0 -104
  237. package/config/getHttpsConfig.js +0 -66
  238. package/config/jest/cssTransform.js +0 -14
  239. package/config/jest/fileTransform.js +0 -40
  240. package/config/modules.js +0 -134
  241. package/config/paths.js +0 -71
  242. package/config/pnpTs.js +0 -35
  243. package/config/webpack.config.js +0 -835
  244. package/config/webpackDevServer.config.js +0 -130
  245. package/examples.tsx +0 -82
  246. package/index.js +0 -1
  247. package/logo.svg +0 -7
  248. package/public/favicon.ico +0 -0
  249. package/public/index.html +0 -43
  250. package/public/logo192.png +0 -0
  251. package/public/logo512.png +0 -0
  252. package/public/manifest.json +0 -25
  253. package/public/robots.txt +0 -3
  254. package/react-app-env.d.ts +0 -71
  255. package/reportWebVitals.ts +0 -15
  256. package/scripts/build.js +0 -208
  257. package/scripts/lib.js +0 -200
  258. package/scripts/publish.js +0 -57
  259. package/scripts/start.js +0 -162
  260. package/scripts/test.js +0 -49
  261. package/setupTests.ts +0 -5
  262. package/tsconfig.json +0 -30
@@ -1,84 +0,0 @@
1
- import React, { FC, useState } from 'react'
2
- import { Button, Form, Input, message } from 'antd'
3
- import { useGuardContext } from '../../../context/global/context'
4
- import { MFACheckEmailFormProps } from '../../types'
5
- import './style.less'
6
- import { useTranslation } from 'react-i18next'
7
- import { VALIDATE_PATTERN } from '../../../_utils'
8
-
9
- export const CheckEmailForm: FC<MFACheckEmailFormProps> = ({
10
- onSuccess,
11
- mfaToken,
12
- }) => {
13
- const {
14
- state: { authClient },
15
- } = useGuardContext()
16
-
17
- const { t } = useTranslation()
18
-
19
- const [rawForm] = Form.useForm()
20
-
21
- const [loading, setLoading] = useState(false)
22
-
23
- const onFinish = async ({ email }: any) => {
24
- try {
25
- const bindable = await authClient.mfa.phoneOrEmailBindable({
26
- mfaToken,
27
- email,
28
- })
29
- if (!bindable) {
30
- message.error(
31
- t('common.unBindEmaileDoc', {
32
- email: email,
33
- })
34
- )
35
- return
36
- }
37
- onSuccess(email!)
38
- } catch (e) {
39
- // do nothing
40
- } finally {
41
- setLoading(false)
42
- }
43
- }
44
-
45
- return (
46
- <>
47
- <h3 className="authing-guard-mfa-title">{t('common.bindEmail')}</h3>
48
- <p className="authing-guard-mfa-tips">{t('common.bindEmailDoc')}</p>
49
- <Form
50
- form={rawForm}
51
- onSubmitCapture={() => setLoading(true)}
52
- onFinish={onFinish}
53
- onFinishFailed={() => setLoading(false)}
54
- >
55
- <Form.Item
56
- name="email"
57
- rules={[
58
- {
59
- required: true,
60
- message: t('login.inputEmail'),
61
- },
62
- {
63
- pattern: VALIDATE_PATTERN.email,
64
- message: t('login.emailError'),
65
- },
66
- ]}
67
- >
68
- <Input placeholder={t('login.inputEmail')}></Input>
69
- </Form.Item>
70
-
71
- <Button
72
- className="authing-guard-mfa-confirm-btn"
73
- loading={loading}
74
- block
75
- htmlType="submit"
76
- type="primary"
77
- size="large"
78
- >
79
- {t('common.sure')}
80
- </Button>
81
- </Form>
82
- </>
83
- )
84
- }
@@ -1,116 +0,0 @@
1
- import { EmailScene, 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 { EmailMFAVerifyFormProps } from '../../../../components/AuthingGuard/types'
8
-
9
- import './style.less'
10
- import { SendCodeBtn } from '../SendPhoneCode/SendCodeBtn'
11
- import { useTranslation } from 'react-i18next'
12
-
13
- const CODE_LEN = 4
14
-
15
- export const VerifyCodeForm: FC<EmailMFAVerifyFormProps> = ({
16
- onSuccess,
17
- onFail,
18
- email,
19
- mfaToken,
20
- sendCodeRef,
21
- }) => {
22
- const {
23
- state: { authClient },
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 [sending, setSending] = useState(false)
34
- const [sent, setSent] = useState(false)
35
-
36
- const onFinish = async (values: any) => {
37
- try {
38
- const user: User = await authClient.mfa.verifyAppEmailMfa({
39
- mfaToken,
40
- email: email!,
41
- code: MfaCode.join(''),
42
- })
43
- onSuccess && onSuccess(user)
44
- } catch (e) {
45
- onFail?.(e)
46
- } finally {
47
- setLoading(false)
48
- }
49
- }
50
-
51
- const sendVerifyCode = async () => {
52
- try {
53
- setSending(true)
54
- await authClient.sendEmail(email!, EmailScene.MfaVerify)
55
- setSent(true)
56
- return true
57
- } catch (e) {
58
- return false
59
- } finally {
60
- setSending(false)
61
- }
62
- }
63
-
64
- return (
65
- <>
66
- <h3 className="authing-guard-mfa-title">{t('login.inputEmailCode')}</h3>
67
- <p className="authing-guard-mfa-tips">
68
- {sending
69
- ? t('login.sendingVerifyCode')
70
- : sent
71
- ? `${t('login.verifyCodeSended')} ${email}`
72
- : t('login.clickSent')}
73
- </p>
74
- <Form
75
- form={rawForm}
76
- onSubmitCapture={() => setLoading(true)}
77
- onFinish={onFinish}
78
- onFinishFailed={() => setLoading(false)}
79
- >
80
- <Form.Item
81
- name="mfaCode"
82
- rules={[
83
- {
84
- validateTrigger: [],
85
- validator() {
86
- if (MfaCode.some((item) => !item)) {
87
- return Promise.reject(t('login.inputFullMfaCode'))
88
- }
89
- return Promise.resolve()
90
- },
91
- },
92
- ]}
93
- >
94
- <VerifyCodeInput
95
- length={CODE_LEN}
96
- verifyCode={MfaCode}
97
- setVerifyCode={setMFACode}
98
- />
99
- </Form.Item>
100
-
101
- <SendCodeBtn btnRef={sendCodeRef} beforeSend={() => sendVerifyCode()} />
102
-
103
- <Button
104
- className="authing-guard-mfa-confirm-btn"
105
- loading={loading}
106
- block
107
- htmlType="submit"
108
- type="primary"
109
- size="large"
110
- >
111
- {t('common.sure')}
112
- </Button>
113
- </Form>
114
- </>
115
- )
116
- }
@@ -1,40 +0,0 @@
1
- import React, { FC, useRef, useState } from 'react'
2
- import { useGuardContext } from '../../../context/global/context'
3
- import { CheckEmailForm } from './CheckEmailForm'
4
- import { VerifyCodeForm } from './VerifyCodeForm'
5
- import { SmsMFAFormProps } from '../../types'
6
-
7
- export const EmailMfaVerifyForm: FC<SmsMFAFormProps> = ({
8
- onSuccess,
9
- onFail,
10
- }) => {
11
- const {
12
- state: {
13
- mfaData: { mfaToken, email: userEmail },
14
- },
15
- } = useGuardContext()
16
- const [email, setEmail] = useState(userEmail)
17
- const sendCodeRef = useRef<HTMLButtonElement>(null)
18
-
19
- return (
20
- <>
21
- {email ? (
22
- <VerifyCodeForm
23
- sendCodeRef={sendCodeRef}
24
- onSuccess={onSuccess}
25
- onFail={onFail}
26
- email={email!}
27
- mfaToken={mfaToken}
28
- ></VerifyCodeForm>
29
- ) : (
30
- <CheckEmailForm
31
- mfaToken={mfaToken}
32
- onSuccess={(email) => {
33
- setEmail(email)
34
- sendCodeRef.current?.click()
35
- }}
36
- ></CheckEmailForm>
37
- )}
38
- </>
39
- )
40
- }
@@ -1,181 +0,0 @@
1
- import React, { forwardRef, useImperativeHandle, useState } from 'react'
2
- import { Input, Form, message } from 'antd'
3
- import { FormInstance } from 'antd/lib/form'
4
- import { UserOutlined, LockOutlined } from '@ant-design/icons'
5
-
6
- import {
7
- getDeviceName,
8
- getRequiredRules,
9
- getUserRegisterParams,
10
- VALIDATE_PATTERN,
11
- } from '../../../_utils'
12
- import { useGuardContext } from '../../../context/global/context'
13
- import {
14
- EmailRegisterFormProps,
15
- RegisterMethods,
16
- } from '../../../../components/AuthingGuard/types'
17
- import { RegisterFormFooter } from '../../../../components/AuthingGuard/Forms/RegisterFormFooter'
18
- import { useTranslation } from 'react-i18next'
19
- import { Agreements } from '../Agreements'
20
-
21
- export const EmailRegisterForm = forwardRef<
22
- FormInstance,
23
- EmailRegisterFormProps
24
- >(({ onSuccess, onFail, onValidateFail }, ref) => {
25
- const { t } = useTranslation()
26
- const {
27
- state: { authClient, config, guardEvents },
28
- } = useGuardContext()
29
-
30
- const { agreements, agreementEnabled } = config
31
-
32
- const [rawForm] = Form.useForm()
33
-
34
- const [loading, setLoading] = useState(false)
35
-
36
- const onFinishFailed = (errorInfo: any) => {
37
- setLoading(false)
38
- onValidateFail && onValidateFail(errorInfo)
39
- }
40
-
41
- const [acceptedAgreements, setAcceptedAgreements] = useState(false)
42
-
43
- /** 表单是否被提交校验过 */
44
- const [validated, setValidated] = useState(false)
45
-
46
- const onFinish = async (values: any) => {
47
- if (guardEvents.onBeforeRegister) {
48
- try {
49
- const canRegister = await guardEvents.onBeforeRegister(
50
- {
51
- type: RegisterMethods.Email,
52
- data: {
53
- email: values.email,
54
- password: values.password,
55
- },
56
- },
57
- authClient
58
- )
59
-
60
- if (!canRegister) {
61
- setLoading(false)
62
- return
63
- }
64
- } catch (e) {
65
- if (typeof e === 'string') {
66
- message.error(e)
67
- } else {
68
- message.error(e.message)
69
- }
70
- setLoading(false)
71
- return
72
- }
73
- }
74
-
75
- try {
76
- await rawForm.validateFields()
77
-
78
- setValidated(true)
79
-
80
- if (agreementEnabled && agreements?.length && !acceptedAgreements) {
81
- return
82
- }
83
-
84
- const { email, password } = values
85
- // 注册并获取登录态
86
- const user = await authClient.registerByEmail(
87
- email,
88
- password,
89
- {
90
- browser:
91
- typeof navigator !== 'undefined' ? navigator.userAgent : null,
92
- device: getDeviceName(),
93
- },
94
- {
95
- generateToken: true,
96
- params: getUserRegisterParams(),
97
- }
98
- )
99
- onSuccess && onSuccess(user)
100
- } catch (error) {
101
- onFail && onFail(error)
102
- } finally {
103
- setLoading(false)
104
- }
105
- }
106
-
107
- useImperativeHandle(ref, () => rawForm)
108
-
109
- const formItems = [
110
- {
111
- component: (
112
- <Input
113
- autoComplete="email"
114
- size="large"
115
- placeholder={t('login.inputEmail')}
116
- prefix={<UserOutlined style={{ color: '#ddd' }} />}
117
- />
118
- ),
119
- name: 'email',
120
- rules: getRequiredRules(t('common.emailNotNull')).concat({
121
- pattern: VALIDATE_PATTERN.email,
122
- message: t('login.emailError'),
123
- }),
124
- },
125
- {
126
- component: (
127
- <Input.Password
128
- size="large"
129
- placeholder={t('common.setPassword')}
130
- prefix={<LockOutlined style={{ color: '#ddd' }} />}
131
- />
132
- ),
133
- name: 'password',
134
- rules: getRequiredRules(t('common.passwordNotNull')),
135
- },
136
- {
137
- component: (
138
- <Input.Password
139
- size="large"
140
- placeholder={t('login.inputPwdAgain')}
141
- prefix={<LockOutlined style={{ color: '#ddd' }} />}
142
- />
143
- ),
144
- name: 'new-password',
145
- rules: getRequiredRules(t('common.repeatPassword')).concat({
146
- validator: (rule, value) => {
147
- if (value !== rawForm.getFieldValue('password')) {
148
- return Promise.reject(t('common.repeatPasswordDoc'))
149
- } else {
150
- return Promise.resolve()
151
- }
152
- },
153
- }),
154
- },
155
- ]
156
-
157
- return (
158
- <Form
159
- form={rawForm}
160
- onFinish={onFinish}
161
- onSubmitCapture={() => setLoading(true)}
162
- onFinishFailed={onFinishFailed}
163
- >
164
- {formItems.map((item) => (
165
- <Form.Item key={item.name} name={item.name} rules={item.rules}>
166
- {item.component}
167
- </Form.Item>
168
- ))}
169
-
170
- {config.agreementEnabled && Boolean(agreements?.length) && (
171
- <Agreements
172
- onChange={setAcceptedAgreements}
173
- agreements={agreements}
174
- showError={validated}
175
- />
176
- )}
177
-
178
- <RegisterFormFooter loading={loading} />
179
- </Form>
180
- )
181
- })
@@ -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
- }