@authing/react-ui-components 3.0.2-beta.6 → 3.0.3-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 (262) hide show
  1. package/lib/index.d.ts +718 -19
  2. package/lib/index.min.css +2 -2
  3. package/lib/index.min.js +1 -1
  4. package/lib/index.min.js.LICENSE.txt +10 -0
  5. package/package.json +34 -11
  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/asset-manifest.json +0 -26
  11. package/build/favicon.ico +0 -0
  12. package/build/index.html +0 -1
  13. package/build/logo192.png +0 -0
  14. package/build/logo512.png +0 -0
  15. package/build/manifest.json +0 -25
  16. package/build/robots.txt +0 -3
  17. package/build/static/css/2.d6432d93.chunk.css +0 -3
  18. package/build/static/css/2.d6432d93.chunk.css.map +0 -1
  19. package/build/static/css/main.6a8701e8.chunk.css +0 -2
  20. package/build/static/css/main.6a8701e8.chunk.css.map +0 -1
  21. package/build/static/js/2.9e599951.chunk.js +0 -3
  22. package/build/static/js/2.9e599951.chunk.js.LICENSE.txt +0 -102
  23. package/build/static/js/2.9e599951.chunk.js.map +0 -1
  24. package/build/static/js/3.ed27e06b.chunk.js +0 -2
  25. package/build/static/js/3.ed27e06b.chunk.js.map +0 -1
  26. package/build/static/js/main.bdf1d850.chunk.js +0 -2
  27. package/build/static/js/main.bdf1d850.chunk.js.map +0 -1
  28. package/build/static/js/runtime-main.9a428724.js +0 -2
  29. package/build/static/js/runtime-main.9a428724.js.map +0 -1
  30. package/build/static/media/loading.4a67a5f3.svg +0 -29
  31. package/components/AuthingDropdown/index.tsx +0 -52
  32. package/components/AuthingDropdown/style.less +0 -43
  33. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  34. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  35. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  36. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  37. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  38. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  39. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  40. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  41. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  42. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  43. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  44. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  45. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  46. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  47. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  48. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  49. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  50. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  51. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  52. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  53. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  54. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  55. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  56. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  57. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  58. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  59. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  60. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  61. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  62. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  63. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  64. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  65. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  66. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  67. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  68. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  69. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  70. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  71. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  72. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  73. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  74. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  75. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  76. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  77. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  78. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  79. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  80. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  81. package/components/AuthingGuard/Forms/index.ts +0 -13
  82. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  83. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  84. package/components/AuthingGuard/Header/index.tsx +0 -25
  85. package/components/AuthingGuard/Header/style.less +0 -52
  86. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  87. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  88. package/components/AuthingGuard/IconFont/style.less +0 -6
  89. package/components/AuthingGuard/IconFont/svg.js +0 -2
  90. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  91. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  92. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  93. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  94. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  95. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  96. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  97. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  98. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  99. package/components/AuthingGuard/api/appConfig.ts +0 -146
  100. package/components/AuthingGuard/api/index.ts +0 -3
  101. package/components/AuthingGuard/api/sso.ts +0 -29
  102. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  103. package/components/AuthingGuard/constants.ts +0 -107
  104. package/components/AuthingGuard/hooks/index.tsx +0 -70
  105. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  106. package/components/AuthingGuard/index.tsx +0 -126
  107. package/components/AuthingGuard/style.less +0 -103
  108. package/components/AuthingGuard/types/Forms.ts +0 -94
  109. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  110. package/components/AuthingGuard/types/GuardState.ts +0 -7
  111. package/components/AuthingGuard/types/Locales.ts +0 -12
  112. package/components/AuthingGuard/types/index.ts +0 -4
  113. package/components/AuthingTabs/index.tsx +0 -98
  114. package/components/AuthingTabs/style.less +0 -135
  115. package/components/BindTotp/core/bindSuccess.tsx +0 -72
  116. package/components/BindTotp/core/securityCode.tsx +0 -108
  117. package/components/BindTotp/index.tsx +0 -134
  118. package/components/BindTotp/interface.ts +0 -30
  119. package/components/BindTotp/styles.less +0 -57
  120. package/components/ChangeLanguage/index.tsx +0 -35
  121. package/components/ChangePassword/core/firstLoginReset.tsx +0 -111
  122. package/components/ChangePassword/core/rotateReset.tsx +0 -125
  123. package/components/ChangePassword/index.tsx +0 -72
  124. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  125. package/components/CompleteInfo/index.tsx +0 -45
  126. package/components/CompleteInfo/interface.ts +0 -40
  127. package/components/CompleteInfo/styles.less +0 -7
  128. package/components/CopyAbleText/index.tsx +0 -54
  129. package/components/CopyAbleText/style.less +0 -13
  130. package/components/DownloadAuthenticator/index.tsx +0 -97
  131. package/components/DownloadAuthenticator/interface.ts +0 -22
  132. package/components/DownloadAuthenticator/styles.less +0 -52
  133. package/components/Error/index.tsx +0 -21
  134. package/components/Error/interface.ts +0 -9
  135. package/components/Error/styles.less +0 -12
  136. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  137. package/components/ForgetPassword/index.tsx +0 -78
  138. package/components/ForgetPassword/interface.ts +0 -32
  139. package/components/Guard/Guard.tsx +0 -295
  140. package/components/Guard/authClient.ts +0 -44
  141. package/components/Guard/config.ts +0 -19
  142. package/components/Guard/event.ts +0 -52
  143. package/components/Guard/index.tsx +0 -4
  144. package/components/Guard/module.ts +0 -20
  145. package/components/Guard/stateMachine.ts +0 -152
  146. package/components/Guard/styles.less +0 -461
  147. package/components/IconFont/iconfont.js +0 -74
  148. package/components/IconFont/index.tsx +0 -16
  149. package/components/IconFont/style.less +0 -6
  150. package/components/IconFont/svg.js +0 -2
  151. package/components/ImagePro/index.tsx +0 -53
  152. package/components/ImagePro/styles.less +0 -40
  153. package/components/InputNumber/index.tsx +0 -33
  154. package/components/Login/codemap.ts +0 -49
  155. package/components/Login/core/withAD.tsx +0 -9
  156. package/components/Login/core/withAppQrcode.tsx +0 -49
  157. package/components/Login/core/withLDAP.tsx +0 -146
  158. package/components/Login/core/withPassword/FormItemAccount.tsx +0 -42
  159. package/components/Login/core/withPassword/GraphicVerifyCode.tsx +0 -30
  160. package/components/Login/core/withPassword/InputAccount.tsx +0 -64
  161. package/components/Login/core/withPassword/index.tsx +0 -173
  162. package/components/Login/core/withPhonecode.tsx +0 -122
  163. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  164. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  165. package/components/Login/index.tsx +0 -374
  166. package/components/Login/interface.ts +0 -74
  167. package/components/Login/socialLogin/index.tsx +0 -407
  168. package/components/Login/socialLogin/style.less +0 -69
  169. package/components/Login/styles.less +0 -53
  170. package/components/MFA/VerifyCodeInput/VerifyCodeFormItem.tsx +0 -41
  171. package/components/MFA/VerifyCodeInput/index.tsx +0 -145
  172. package/components/MFA/VerifyCodeInput/style.less +0 -35
  173. package/components/MFA/codemap.ts +0 -24
  174. package/components/MFA/core/email.tsx +0 -203
  175. package/components/MFA/core/face.tsx +0 -297
  176. package/components/MFA/core/face_deps.tsx +0 -37
  177. package/components/MFA/core/sms.tsx +0 -203
  178. package/components/MFA/core/totp.tsx +0 -122
  179. package/components/MFA/index.tsx +0 -143
  180. package/components/MFA/interface.ts +0 -51
  181. package/components/MFA/mfaMethods/index.tsx +0 -88
  182. package/components/MFA/mfaMethods/style.less +0 -39
  183. package/components/MFA/styles.less +0 -100
  184. package/components/NeedHelpView/core/describeQuestions.tsx +0 -245
  185. package/components/NeedHelpView/index.tsx +0 -47
  186. package/components/RecoveryCode/core/useCode.tsx +0 -71
  187. package/components/RecoveryCode/index.tsx +0 -27
  188. package/components/RecoveryCode/interface.ts +0 -31
  189. package/components/RecoveryCode/style.less +0 -13
  190. package/components/Register/codemap.ts +0 -12
  191. package/components/Register/components/Agreements/index.tsx +0 -81
  192. package/components/Register/components/Agreements/style.less +0 -44
  193. package/components/Register/core/WithEmail.tsx +0 -242
  194. package/components/Register/core/WithPhone.tsx +0 -184
  195. package/components/Register/index.tsx +0 -139
  196. package/components/Register/interface.ts +0 -50
  197. package/components/SendCode/SendCodeBtn.tsx +0 -96
  198. package/components/SendCode/index.tsx +0 -94
  199. package/components/SendCode/style.less +0 -31
  200. package/components/ShieldSpin/index.tsx +0 -27
  201. package/components/ShieldSpin/loading.svg +0 -29
  202. package/components/SubmitButton/index.tsx +0 -50
  203. package/components/SubmitSuccess/index.tsx +0 -66
  204. package/components/SubmitSuccess/interface.ts +0 -17
  205. package/components/Type/index.ts +0 -52
  206. package/components/ValidatorRules/ValidatorFormItem.tsx +0 -139
  207. package/components/ValidatorRules/index.ts +0 -20
  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 -116
  213. package/components/_utils/guradHttp.ts +0 -101
  214. package/components/_utils/hooks/index.ts +0 -64
  215. package/components/_utils/http.ts +0 -85
  216. package/components/_utils/index.ts +0 -326
  217. package/components/_utils/locales/en/common.json +0 -229
  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 -229
  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 -83
  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 -9
  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 -87
  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,111 +0,0 @@
1
- import React, { useRef } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { Form, Input, message } 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
- submitButtonRef.current?.onSpin(false)
25
- try {
26
- let res = await client.resetPasswordByFirstLoginToken({
27
- token: props.initData.token,
28
- password: newPassword,
29
- })
30
- props.onReset(res)
31
- } catch (error) {
32
- message.error(error.message)
33
- submitButtonRef?.current?.onError()
34
- } finally {
35
- submitButtonRef.current?.onSpin(false)
36
- }
37
- }
38
-
39
- return (
40
- <div className="authing-g2-login-phone-code">
41
- <Form
42
- name="resetPassword"
43
- form={form}
44
- onFinish={onFinish}
45
- onFinishFailed={() => {
46
- submitButtonRef?.current?.onError()
47
- }}
48
- autoComplete="off"
49
- >
50
- <Form.Item
51
- className="authing-g2-input-form"
52
- name="password"
53
- rules={[
54
- {
55
- validator(_, value) {
56
- if (value && value.indexOf(' ') !== -1) {
57
- return Promise.reject(t('common.checkPasswordHasSpace'))
58
- }
59
- return Promise.resolve()
60
- },
61
- },
62
- ...getPasswordValidate(
63
- props.publicConfig?.passwordStrength,
64
- props.publicConfig?.customPasswordStrength
65
- ),
66
- ]}
67
- >
68
- <Input.Password
69
- className="authing-g2-input"
70
- size="large"
71
- placeholder={t('login.inputPwd')}
72
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
73
- />
74
- </Form.Item>
75
- <Form.Item
76
- className="authing-g2-input-form"
77
- name="password2"
78
- rules={[
79
- {
80
- validator(_, value) {
81
- let pwd = form.getFieldValue('password')
82
- if (!value) {
83
- return Promise.reject(t('login.inputPwd'))
84
- }
85
- if (value !== pwd) {
86
- return Promise.reject(t('common.repeatPasswordDoc'))
87
- }
88
- return Promise.resolve()
89
- },
90
- },
91
- ]}
92
- >
93
- <Input.Password
94
- className="authing-g2-input"
95
- size="large"
96
- placeholder={t('login.inputPwdAgain')}
97
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
98
- />
99
- </Form.Item>
100
-
101
- <Form.Item className="authing-g2-input-form submit-form">
102
- <SubmitButton
103
- className="forget-password"
104
- text={t('common.confirm')}
105
- ref={submitButtonRef}
106
- />
107
- </Form.Item>
108
- </Form>
109
- </div>
110
- )
111
- }
@@ -1,125 +0,0 @@
1
- import React, { useRef } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { Form, Input, message } from 'antd'
4
-
5
- import { LockOutlined } from '@ant-design/icons'
6
-
7
- import { getPasswordValidate } from '../../_utils'
8
- import SubmitButton from '../../SubmitButton'
9
- import { useAuthClient } from '../../Guard/authClient'
10
-
11
- interface RotateResetProps {
12
- onReset: any
13
- publicConfig: any
14
- initData: any
15
- }
16
-
17
- export const RotateReset = (props: RotateResetProps) => {
18
- const { t } = useTranslation()
19
- let [form] = Form.useForm()
20
- let authClient = useAuthClient()
21
- let submitButtonRef = useRef<any>(null)
22
-
23
- const onFinish = async (values: any) => {
24
- let { password, oldPassword } = values
25
- submitButtonRef?.current?.onSpin(true)
26
-
27
- try {
28
- let res = await authClient.resetPasswordByForceResetToken({
29
- token: props.initData.token,
30
- newPassword: password,
31
- oldPassword: oldPassword,
32
- })
33
- props.onReset(res)
34
- } catch (error) {
35
- message.error(error.message)
36
- submitButtonRef?.current?.onError()
37
- } finally {
38
- submitButtonRef?.current?.onSpin(false)
39
- }
40
- }
41
-
42
- return (
43
- <div className="authing-g2-login-phone-code">
44
- <Form
45
- name="resetPassword"
46
- form={form}
47
- onFinish={onFinish}
48
- onFinishFailed={() => {
49
- submitButtonRef?.current?.onError()
50
- }}
51
- autoComplete="off"
52
- >
53
- <Form.Item
54
- className="authing-g2-input-form"
55
- name="oldPassword"
56
- rules={[{ required: true }]}
57
- >
58
- <Input.Password
59
- className="authing-g2-input"
60
- size="large"
61
- placeholder={t('user.inputCurrPwd')}
62
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
63
- />
64
- </Form.Item>
65
- <Form.Item
66
- className="authing-g2-input-form"
67
- name="password"
68
- rules={[
69
- {
70
- validator(_, value) {
71
- if (value && value.indexOf(' ') !== -1) {
72
- return Promise.reject(t('common.checkPasswordHasSpace'))
73
- }
74
- return Promise.resolve()
75
- },
76
- },
77
- ...getPasswordValidate(
78
- props.publicConfig?.passwordStrength,
79
- props.publicConfig?.customPasswordStrength
80
- ),
81
- ]}
82
- >
83
- <Input.Password
84
- className="authing-g2-input"
85
- size="large"
86
- placeholder={t('login.inputPwd')}
87
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
88
- />
89
- </Form.Item>
90
- <Form.Item
91
- className="authing-g2-input-form"
92
- name="password2"
93
- rules={[
94
- {
95
- validator(_, value) {
96
- let pwd = form.getFieldValue('password')
97
- if (!value) {
98
- return Promise.reject(t('login.inputPwd'))
99
- }
100
- if (value !== pwd) {
101
- return Promise.reject(t('common.repeatPasswordDoc'))
102
- }
103
- return Promise.resolve()
104
- },
105
- },
106
- ]}
107
- >
108
- <Input.Password
109
- className="authing-g2-input"
110
- size="large"
111
- placeholder={t('login.inputPwdAgain')}
112
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
113
- />
114
- </Form.Item>
115
- <Form.Item className="authing-g2-input-form submit-form">
116
- <SubmitButton
117
- className="forget-password"
118
- text={t('common.confirm')}
119
- ref={submitButtonRef}
120
- />
121
- </Form.Item>
122
- </Form>
123
- </div>
124
- )
125
- }
@@ -1,72 +0,0 @@
1
- import React, { useMemo } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { GuardModuleType } from '../Guard/module'
4
- import { ImagePro } from '../ImagePro'
5
- import { FirstLoginReset } from './core/firstLoginReset'
6
- import { RotateReset } from './core/rotateReset'
7
-
8
- // 手动修改密码,并非「忘记密码」
9
- // 进入的场景是读取配置:1开了首次登录修改密码 || 2开了密码轮换
10
- export const GuardChangePassword = (props: any) => {
11
- let { initData, config } = props
12
- let publicConfig = config.__publicConfig__
13
- const { t } = useTranslation()
14
-
15
- const onReset = (res: any) => {
16
- let code = res.code
17
- if (code === 200) {
18
- // 返回登录
19
- props.__changeModule(GuardModuleType.LOGIN)
20
- } else {
21
- console.log('*** reset code no catched', res)
22
- }
23
- }
24
-
25
- const typeContent = useMemo(() => {
26
- if (initData.type === 'inital') {
27
- return {
28
- title: `${t('common.welcome')} ${config.title}`,
29
- explain: t('common.initPasswordText'),
30
- }
31
- } else {
32
- return {
33
- title: t('user.modifyPwd'),
34
- explain: t('user.modifyPwdText', {
35
- number: 1,
36
- }),
37
- }
38
- }
39
- }, [config.title, initData.type, t])
40
-
41
- return (
42
- <div className="g2-view-container">
43
- <div className="g2-view-header">
44
- <ImagePro
45
- src={config?.logo}
46
- size={48}
47
- borderRadius={4}
48
- alt=""
49
- className="icon"
50
- />
51
- <div className="title">{typeContent.title}</div>
52
- <div className="title-explain">{typeContent.explain}</div>
53
- </div>
54
- <div className="g2-view-tabs">
55
- {initData.type === 'inital' && (
56
- <FirstLoginReset
57
- onReset={onReset}
58
- initData={initData}
59
- publicConfig={publicConfig}
60
- />
61
- )}
62
- {initData.type === 'rotate' && (
63
- <RotateReset
64
- onReset={onReset}
65
- initData={initData}
66
- publicConfig={publicConfig}
67
- />
68
- )}
69
- </div>
70
- </div>
71
- )
72
- }
@@ -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 getDefaultCompleteInfoConfig = (): 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
- }