@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,104 +0,0 @@
1
- import React, { useRef } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { Form, Input } from 'antd'
4
-
5
- import { LockOutlined } from '@ant-design/icons'
6
-
7
- import { useAuthClient } from '../../Guard/authClient'
8
- import { getPasswordValidate } from '../../_utils'
9
- import SubmitButton from '../../SubmitButton'
10
-
11
- interface FirstLoginResetProps {
12
- onReset: any
13
- publicConfig: any
14
- initData: any
15
- }
16
- export const FirstLoginReset = (props: FirstLoginResetProps) => {
17
- const { t } = useTranslation()
18
- let [form] = Form.useForm()
19
- let client = useAuthClient()
20
- let submitButtonRef = useRef<any>(null)
21
-
22
- const onFinish = async (values: any) => {
23
- let newPassword = values.password
24
- // let newPassword2 = values.password2
25
- let res = await client.resetPasswordByFirstLoginToken({
26
- token: props.initData.token,
27
- password: newPassword,
28
- })
29
- props.onReset(res)
30
- }
31
-
32
- return (
33
- <div className="authing-g2-login-phone-code">
34
- <Form
35
- name="resetPassword"
36
- form={form}
37
- onFinish={onFinish}
38
- onFinishFailed={() => {
39
- submitButtonRef?.current?.onError()
40
- }}
41
- autoComplete="off"
42
- >
43
- <Form.Item
44
- className="authing-g2-input-form"
45
- name="password"
46
- rules={[
47
- {
48
- validator(_, value) {
49
- if (value && value.indexOf(' ') !== -1) {
50
- return Promise.reject(t('common.checkPasswordHasSpace'))
51
- }
52
- return Promise.resolve()
53
- },
54
- },
55
- ...getPasswordValidate(
56
- props.publicConfig?.passwordStrength,
57
- props.publicConfig?.customPasswordStrength
58
- ),
59
- ]}
60
- >
61
- <Input.Password
62
- className="authing-g2-input"
63
- size="large"
64
- placeholder={t('login.inputPwd')}
65
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
66
- />
67
- </Form.Item>
68
- <Form.Item
69
- className="authing-g2-input-form"
70
- name="password2"
71
- rules={[
72
- {
73
- validator(_, value) {
74
- let pwd = form.getFieldValue('password')
75
- if (!value) {
76
- return Promise.reject(t('login.inputPwd'))
77
- }
78
- if (value !== pwd) {
79
- return Promise.reject(t('common.repeatPasswordDoc'))
80
- }
81
- return Promise.resolve()
82
- },
83
- },
84
- ]}
85
- >
86
- <Input.Password
87
- className="authing-g2-input"
88
- size="large"
89
- placeholder={t('login.inputPwdAgain')}
90
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
91
- />
92
- </Form.Item>
93
-
94
- <Form.Item className="authing-g2-input-form submit-form">
95
- <SubmitButton
96
- className="forget-password"
97
- text={t('common.confirm')}
98
- ref={submitButtonRef}
99
- />
100
- </Form.Item>
101
- </Form>
102
- </div>
103
- )
104
- }
@@ -1,114 +0,0 @@
1
- import React, { useRef } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { Form, Input } from 'antd'
4
-
5
- import { LockOutlined } from '@ant-design/icons'
6
-
7
- import { getPasswordValidate } from '../../_utils'
8
- import SubmitButton from '../../SubmitButton'
9
-
10
- interface RotateResetProps {
11
- onReset: any
12
- publicConfig: any
13
- initData: any
14
- }
15
-
16
- export const RotateReset = (props: RotateResetProps) => {
17
- const { t } = useTranslation()
18
- let [form] = Form.useForm()
19
- // let client = useAuthClient()
20
- let submitButtonRef = useRef<any>(null)
21
-
22
- const onFinish = async (values: any) => {
23
- // let newPassword = values.password
24
- // let res = await client.resetPasswordByFirstLoginToken({
25
- // token: props.initData.token,
26
- // password: newPassword,
27
- // })
28
- // props.onReset(res)
29
- }
30
-
31
- return (
32
- <div className="authing-g2-login-phone-code">
33
- <Form
34
- name="resetPassword"
35
- form={form}
36
- onFinish={onFinish}
37
- onFinishFailed={() => {
38
- submitButtonRef?.current?.onError()
39
- }}
40
- autoComplete="off"
41
- >
42
- <Form.Item
43
- className="authing-g2-input-form"
44
- name="oldPassword"
45
- rules={[{ required: true }]}
46
- >
47
- <Input.Password
48
- className="authing-g2-input"
49
- size="large"
50
- placeholder={t('user.inputCurrPwd')}
51
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
52
- />
53
- </Form.Item>
54
- <Form.Item
55
- className="authing-g2-input-form"
56
- name="password"
57
- rules={[
58
- {
59
- validator(_, value) {
60
- if (value && value.indexOf(' ') !== -1) {
61
- return Promise.reject(t('common.checkPasswordHasSpace'))
62
- }
63
- return Promise.resolve()
64
- },
65
- },
66
- ...getPasswordValidate(
67
- props.publicConfig?.passwordStrength,
68
- props.publicConfig?.customPasswordStrength
69
- ),
70
- ]}
71
- >
72
- <Input.Password
73
- className="authing-g2-input"
74
- size="large"
75
- placeholder={t('login.inputPwd')}
76
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
77
- />
78
- </Form.Item>
79
- <Form.Item
80
- className="authing-g2-input-form"
81
- name="password2"
82
- rules={[
83
- {
84
- validator(_, value) {
85
- let pwd = form.getFieldValue('password')
86
- if (!value) {
87
- return Promise.reject(t('login.inputPwd'))
88
- }
89
- if (value !== pwd) {
90
- return Promise.reject(t('common.repeatPasswordDoc'))
91
- }
92
- return Promise.resolve()
93
- },
94
- },
95
- ]}
96
- >
97
- <Input.Password
98
- className="authing-g2-input"
99
- size="large"
100
- placeholder={t('login.inputPwdAgain')}
101
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
102
- />
103
- </Form.Item>
104
- <Form.Item className="authing-g2-input-form submit-form">
105
- <SubmitButton
106
- className="forget-password"
107
- text={t('common.confirm')}
108
- ref={submitButtonRef}
109
- />
110
- </Form.Item>
111
- </Form>
112
- </div>
113
- )
114
- }
@@ -1,59 +0,0 @@
1
- import React from 'react'
2
- import { GuardModuleType } from '../Guard/module'
3
- import { ImagePro } from '../ImagePro'
4
- import { FirstLoginReset } from './core/firstLoginReset'
5
- import { RotateReset } from './core/rotateReset'
6
-
7
- // 手动修改密码,并非「忘记密码」
8
- // 进入的场景是读取配置:1开了首次登录修改密码 || 2开了密码轮换
9
- export const GuardChangePassword = (props: any) => {
10
- let { initData, config } = props
11
- let publicConfig = config.__publicConfig__
12
- // let [resetType] = useState<'inital' | 'rotate'>(initData.type) //
13
- // console.log('******', initData.type)
14
- // let publicConfig = props.config.__publicConfig__
15
-
16
- const onReset = (res: any) => {
17
- let code = res.code
18
- if (code === 200) {
19
- // 返回登录
20
- props.__changeModule(GuardModuleType.LOGIN)
21
- } else {
22
- console.log('*** reset code no catched', res)
23
- }
24
- }
25
-
26
- return (
27
- <div className="g2-view-container">
28
- <div className="g2-view-header">
29
- <ImagePro
30
- src={config?.logo}
31
- size={48}
32
- borderRadius={4}
33
- alt=""
34
- className="icon"
35
- />
36
- <div className="title">欢迎访问 {config.title}</div>
37
- <div className="title-explain">
38
- 你的密码连续使用超过 xxx,可能存在风险。请重新设置密码。
39
- </div>
40
- </div>
41
- <div className="g2-view-tabs">
42
- {initData.type === 'inital' && (
43
- <FirstLoginReset
44
- onReset={onReset}
45
- initData={initData}
46
- publicConfig={publicConfig}
47
- />
48
- )}
49
- {initData.type === 'rotate' && (
50
- <RotateReset
51
- onReset={onReset}
52
- initData={initData}
53
- publicConfig={publicConfig}
54
- />
55
- )}
56
- </div>
57
- </div>
58
- )
59
- }
@@ -1,155 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react'
2
- import { Form, Input, message, Select } from 'antd'
3
- import { useTranslation } from 'react-i18next'
4
- import { useAsyncFn } from 'react-use'
5
- import { ExtendsField } from '../../AuthingGuard/api'
6
- import { UploadImage } from '../../AuthingGuard/Forms/UploadImage'
7
- import { useAuthClient } from '../../Guard/authClient'
8
- import { i18n } from '../../_utils/locales'
9
- import { useGuardHttp } from '../../_utils/guradHttp'
10
- import { GuardCompleteInfoViewProps } from '../interface'
11
- import SubmitButton from '../../SubmitButton'
12
-
13
- export interface CompleteInfoProps {
14
- extendsFields: ExtendsField[]
15
- onRegisterInfoCompleted?: GuardCompleteInfoViewProps['onRegisterInfoCompleted']
16
- onRegisterInfoCompletedError?: GuardCompleteInfoViewProps['onRegisterInfoCompletedError']
17
- }
18
-
19
- export const CompleteInfo: React.FC<CompleteInfoProps> = ({
20
- extendsFields,
21
- onRegisterInfoCompleted,
22
- onRegisterInfoCompletedError,
23
- }) => {
24
- const authClient = useAuthClient()
25
- const submitButtonRef = useRef<any>(null)
26
- const { get, post } = useGuardHttp()
27
- const { t } = useTranslation()
28
- const [form] = Form.useForm()
29
-
30
- const [definitions, setDefinitions] = useState<any[]>([])
31
-
32
- const [, loadInitData] = useAsyncFn(async () => {
33
- const user = await authClient.getCurrentUser()
34
-
35
- const { data } = await get<any>('/api/v2/udfs/definitions', undefined, {
36
- headers: {
37
- authorization: user?.token!,
38
- },
39
- })
40
-
41
- setDefinitions(data)
42
- }, [authClient, get])
43
-
44
- useEffect(() => {
45
- loadInitData()
46
- }, [loadInitData])
47
-
48
- const INPUT_MAP: Record<string, React.ReactNode | undefined> = {
49
- image: <UploadImage />,
50
- }
51
- const INTERNAL_INPUT_MAP: Record<string, React.ReactNode | undefined> = {
52
- gender: (
53
- <Select
54
- className="authing-g2-select"
55
- options={[
56
- { label: i18n.t('common.man'), value: 'M' },
57
- { label: i18n.t('common.female'), value: 'F' },
58
- ]}
59
- />
60
- ),
61
- }
62
-
63
- const formFields = extendsFields.map((def) => {
64
- const key = `${def.type} ${def.type === 'internal' ? def.name : def.id}`
65
-
66
- const label = i18n.language === 'zh-CN' ? def.label : def.name
67
-
68
- return (
69
- <Form.Item
70
- key={key}
71
- name={key}
72
- label={label}
73
- // style={{ marginBottom: 24 }}
74
- className="authing-g2-input-form"
75
- rules={[
76
- {
77
- required: true,
78
- message: `${label} ${t('login.noEmpty')}`,
79
- },
80
- ]}
81
- >
82
- {INTERNAL_INPUT_MAP[def.name] || INPUT_MAP[def.inputType] || (
83
- <Input
84
- type={def.inputType}
85
- size="large"
86
- className="authing-g2-input"
87
- autoComplete="tel"
88
- />
89
- )}
90
- </Form.Item>
91
- )
92
- })
93
-
94
- const [, onFinish] = useAsyncFn(async (values: any) => {
95
- submitButtonRef.current?.onSpin(true)
96
-
97
- const internalFields: any = {}
98
- const userFields: any[] = []
99
- Object.entries(values).forEach(([key, value]) => {
100
- const [type, nameOrId] = key.split(' ')
101
- if (type === 'internal') {
102
- internalFields[nameOrId] = value
103
- } else if (type === 'user') {
104
- userFields.push({ nameOrId, value })
105
- }
106
- })
107
-
108
- const udfs = userFields.map(({ nameOrId, value }) => ({
109
- definition: definitions.find((def) => def.id === nameOrId),
110
- value,
111
- }))
112
-
113
- try {
114
- const user = await authClient.updateProfile(internalFields)
115
-
116
- await post(
117
- `/api/v2/udfs/values`,
118
- {
119
- udfs,
120
- },
121
- {
122
- headers: {
123
- authorization: user?.token,
124
- },
125
- }
126
- )
127
- submitButtonRef.current?.onSpin(false)
128
- message.success(t('common.saveSuccess'))
129
- onRegisterInfoCompleted?.(user, udfs, authClient)
130
- } catch (e) {
131
- // TODO
132
- submitButtonRef.current?.onSpin(false)
133
- onRegisterInfoCompletedError?.(e, udfs, authClient)
134
- }
135
- }, [])
136
-
137
- return (
138
- <Form
139
- layout="vertical"
140
- form={form}
141
- onFinish={onFinish}
142
- onFinishFailed={() => submitButtonRef.current.onError()}
143
- >
144
- {formFields}
145
-
146
- <Form.Item className="authing-g2-input-form">
147
- <SubmitButton
148
- text={t('common.problem.form.submit')}
149
- ref={submitButtonRef}
150
- className="password g2-completeInfo-submit"
151
- />
152
- </Form.Item>
153
- </Form>
154
- )
155
- }
@@ -1,45 +0,0 @@
1
- import React from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { ImagePro } from '../ImagePro'
4
- import { GuardModuleType } from '../Guard/module'
5
-
6
- import { CompleteInfo } from './core/completeInfo'
7
- import { GuardCompleteInfoViewProps } from './interface'
8
-
9
- import './styles.less'
10
-
11
- export const GuardCompleteInfoView: React.FC<GuardCompleteInfoViewProps> = ({
12
- config,
13
- onRegisterInfoCompleted,
14
- onRegisterInfoCompletedError,
15
- __changeModule,
16
- }) => {
17
- const { t } = useTranslation()
18
- return (
19
- <div className="g2-view-container">
20
- <div className="g2-view-header">
21
- <ImagePro
22
- src={config?.logo}
23
- size={48}
24
- borderRadius={4}
25
- alt=""
26
- className="icon"
27
- />
28
- <div className="title">{t('common.perfectUserInfo')}</div>
29
- <div className="title-explain">
30
- {t('common.welcomeDoc', { name: config.title })}
31
- </div>
32
- </div>
33
- <div className="g2-view-tabs g2-completeInfo-content">
34
- <CompleteInfo
35
- extendsFields={config?.__publicConfig__?.extendsFields!}
36
- onRegisterInfoCompleted={(user, udfs, authClient) => {
37
- onRegisterInfoCompleted?.(user, udfs, authClient)
38
- __changeModule?.(GuardModuleType.LOGIN, {})
39
- }}
40
- onRegisterInfoCompletedError={onRegisterInfoCompletedError}
41
- />
42
- </div>
43
- </div>
44
- )
45
- }
@@ -1,40 +0,0 @@
1
- import { AuthenticationClient, CommonMessage, User } from 'authing-js-sdk'
2
- import { getDefaultG2Config, IG2Config, IG2Events, IG2FCProps } from '../Type'
3
-
4
- export interface CompleteInfoConfig extends IG2Config {}
5
-
6
- const defaultConfig: CompleteInfoConfig = {
7
- ...getDefaultG2Config(),
8
- }
9
-
10
- export const getDefaultLoginConfig = (): CompleteInfoConfig => ({
11
- ...getDefaultG2Config(),
12
- ...defaultConfig,
13
- })
14
-
15
- export interface CompleteInfoEvents extends IG2Events {
16
- onRegisterInfoCompleted?: (
17
- user: User,
18
- udfs: {
19
- definition: any
20
- value: any
21
- }[],
22
- authClient: AuthenticationClient
23
- ) => void
24
- onRegisterInfoCompletedError?: (
25
- error: CommonMessage,
26
- udfs: {
27
- definition: any
28
- value: any
29
- }[],
30
- authClient: AuthenticationClient
31
- ) => void
32
- }
33
-
34
- export interface GuardCompleteInfoProps extends IG2FCProps, CompleteInfoEvents {
35
- config: Partial<CompleteInfoConfig>
36
- }
37
-
38
- export interface GuardCompleteInfoViewProps extends GuardCompleteInfoProps {
39
- config: CompleteInfoConfig
40
- }
@@ -1,7 +0,0 @@
1
- .g2-completeInfo-content {
2
- margin-bottom: 44px;
3
- }
4
-
5
- .g2-completeInfo-submit {
6
- margin-top: 30px !important;
7
- }
@@ -1,54 +0,0 @@
1
- import React, { FC, useCallback, useEffect, useRef, useState } from 'react'
2
- import { CopyOutlined, CheckOutlined } from '@ant-design/icons'
3
- import { copyToClipboard, getClassnames } from '../_utils'
4
-
5
- import './style.less'
6
- import { useTranslation } from 'react-i18next'
7
-
8
- export interface CopyTextProps extends React.HTMLAttributes<HTMLDivElement> {}
9
-
10
- export const CopyAbleText: FC<CopyTextProps> = ({ children, className }) => {
11
- const { t } = useTranslation()
12
- const divRef = useRef<HTMLDivElement>(null)
13
- const [copied, setCopied] = useState(false)
14
- const timer = useRef(-1)
15
-
16
- const startTimer = useCallback(() => {
17
- setCopied(true)
18
- clearTimeout(timer.current)
19
- timer.current = (setTimeout(
20
- () => setCopied(false),
21
- 3000
22
- ) as unknown) as number
23
- }, [timer])
24
-
25
- useEffect(() => {
26
- return () => clearTimeout(timer.current)
27
- }, [])
28
-
29
- const handleCopy = () => {
30
- copyToClipboard(divRef.current!.innerText)
31
- startTimer()
32
- }
33
-
34
- return (
35
- <div
36
- className={getClassnames(['authing-copy-text', className])}
37
- ref={divRef}
38
- >
39
- {children}
40
- {copied ? (
41
- <CheckOutlined
42
- className="authing-data-tips authing-data-tips__top authing-guard-pointer authing-copy-text-icon authing-copy-text-icon__success"
43
- data-tips={t('common.copied')}
44
- />
45
- ) : (
46
- <CopyOutlined
47
- className="authing-data-tips authing-data-tips__top authing-guard-pointer authing-copy-text-icon"
48
- data-tips={t('common.copy')}
49
- onClick={handleCopy}
50
- />
51
- )}
52
- </div>
53
- )
54
- }
@@ -1,13 +0,0 @@
1
- .authing-copy-text {
2
- display: flex;
3
- align-items: center;
4
- }
5
-
6
- .authing-copy-text-icon {
7
- margin-left: 4px;
8
- color: #396aff;
9
- }
10
-
11
- .authing-copy-text-icon__success {
12
- color: #b7eb8f;
13
- }
@@ -1,97 +0,0 @@
1
- import { Tabs } from 'antd'
2
- import React, { ReactNode, useMemo } from 'react'
3
- import { useTranslation } from 'react-i18next'
4
- import { ImagePro } from '../ImagePro'
5
- import { IconFont } from '../IconFont'
6
- import { GuardDownloadATViewProps } from './interface'
7
- import './styles.less'
8
- const window: Window = require('global/window')
9
-
10
- enum DownloadType {
11
- IOS = 'ios',
12
- Android = 'Android',
13
- }
14
-
15
- export const GuardDownloadATView: React.FC<GuardDownloadATViewProps> = ({
16
- config,
17
- }) => {
18
- const { t } = useTranslation()
19
-
20
- const cdnBase = config.__publicConfig__?.cdnBase
21
-
22
- const downloadConfig: Record<DownloadType, any> = useMemo(
23
- () => ({
24
- [DownloadType.IOS]: {
25
- title: t('common.downloadTotpAppIOS'),
26
- google: `${cdnBase}/GoogleAuthenticator-Apple.png`,
27
- microsoft: `${cdnBase}/MicrosoftAuthenticator-Apple.png`,
28
- },
29
- [DownloadType.Android]: {
30
- title: t('common.downloadTotpAppAndroid'),
31
- google: `${cdnBase}/GoogleAuthenticator-Authing.png`,
32
- microsoft: `${cdnBase}/MicrosoftAuthenticator-Baidu.png`,
33
- },
34
- }),
35
- [cdnBase, t]
36
- )
37
-
38
- const renderTab = useMemo(
39
- () =>
40
- (Object.keys(downloadConfig) as DownloadType[]).map<ReactNode>(
41
- (value: DownloadType, index: number) => (
42
- <Tabs.TabPane
43
- tab={downloadConfig[value].title}
44
- key={index}
45
- className="g2-mfa-download-at-tab"
46
- >
47
- <span className="g2-mfa-totp-download-subtitle">
48
- {t('common.downloadTotpAppDocs')}
49
- </span>
50
- <div className="g2-mfa-totp-download-qrcode">
51
- <div className="g2-mfa-totp-download-qrcode-item">
52
- <ImagePro
53
- width={120}
54
- height={120}
55
- className="g2-mfa-totp-download-image"
56
- src={downloadConfig[value].google}
57
- alt="Google Authenticator"
58
- />
59
- <span className="g2-mfa-totp-download-qrcode-text">
60
- Google Authenticator
61
- </span>
62
- </div>
63
- <div className="g2-mfa-totp-download-qrcode-item">
64
- <ImagePro
65
- width={120}
66
- height={120}
67
- className="g2-mfa-totp-download-image"
68
- src={downloadConfig[value].microsoft}
69
- alt="Microsoft Authenticator"
70
- />
71
- <span className="g2-mfa-totp-download-qrcode-text">
72
- Microsoft Authenticator
73
- </span>
74
- </div>
75
- </div>
76
- </Tabs.TabPane>
77
- )
78
- ),
79
- [downloadConfig, t]
80
- )
81
-
82
- const onBack = () => window.history.back()
83
-
84
- return (
85
- <div className="g2-view-container">
86
- <div className="g2-view-back">
87
- <span onClick={onBack}>
88
- <IconFont type="authing-back" />
89
- <span>{t('common.backToMFA')}</span>
90
- </span>
91
- </div>
92
- <div className="g2-view-tabs g2-mfa-totp-download-tabs">
93
- <Tabs defaultActiveKey={DownloadType.IOS}>{renderTab}</Tabs>
94
- </div>
95
- </div>
96
- )
97
- }