@authing/react-ui-components 3.0.2-beta.1 → 3.0.2-beta.14

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 (263) hide show
  1. package/lib/index.d.ts +555 -46
  2. package/lib/index.min.css +2 -2
  3. package/lib/index.min.js +1 -1
  4. package/lib/index.min.js.LICENSE.txt +2 -0
  5. package/package.json +30 -10
  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.9512539b.chunk.css +0 -3
  18. package/build/static/css/2.9512539b.chunk.css.map +0 -1
  19. package/build/static/css/main.0ff9e24a.chunk.css +0 -2
  20. package/build/static/css/main.0ff9e24a.chunk.css.map +0 -1
  21. package/build/static/js/2.1105ecfb.chunk.js +0 -3
  22. package/build/static/js/2.1105ecfb.chunk.js.LICENSE.txt +0 -102
  23. package/build/static/js/2.1105ecfb.chunk.js.map +0 -1
  24. package/build/static/js/3.fd17f196.chunk.js +0 -2
  25. package/build/static/js/3.fd17f196.chunk.js.map +0 -1
  26. package/build/static/js/main.a47645ff.chunk.js +0 -2
  27. package/build/static/js/main.a47645ff.chunk.js.map +0 -1
  28. package/build/static/js/runtime-main.ef138021.js +0 -2
  29. package/build/static/js/runtime-main.ef138021.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 -73
  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 -104
  122. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  123. package/components/ChangePassword/index.tsx +0 -59
  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 -255
  140. package/components/Guard/authClient.ts +0 -46
  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 -133
  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 -47
  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 -31
  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 -373
  166. package/components/Login/props.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 -204
  178. package/components/MFA/core/totp.tsx +0 -122
  179. package/components/MFA/index.tsx +0 -143
  180. package/components/MFA/mfaMethods/index.tsx +0 -88
  181. package/components/MFA/mfaMethods/style.less +0 -39
  182. package/components/MFA/props.ts +0 -51
  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 -239
  194. package/components/Register/core/WithPhone.tsx +0 -184
  195. package/components/Register/index.tsx +0 -138
  196. package/components/Register/props.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/EmailFormItem.tsx +0 -95
  207. package/components/ValidatorRules/PhoneFormItem.tsx +0 -100
  208. package/components/ValidatorRules/index.ts +0 -14
  209. package/components/VerifyCodeInput/index.tsx +0 -76
  210. package/components/VerifyCodeInput/style.less +0 -24
  211. package/components/_utils/GuardErrorCode.ts +0 -9
  212. package/components/_utils/clipboard.ts +0 -27
  213. package/components/_utils/config.ts +0 -118
  214. package/components/_utils/guradHttp.ts +0 -97
  215. package/components/_utils/hooks/index.ts +0 -64
  216. package/components/_utils/http.ts +0 -85
  217. package/components/_utils/index.ts +0 -322
  218. package/components/_utils/locales/en/common.json +0 -227
  219. package/components/_utils/locales/en/index.ts +0 -6
  220. package/components/_utils/locales/en/login.json +0 -96
  221. package/components/_utils/locales/en/map.json +0 -4
  222. package/components/_utils/locales/en/user.json +0 -82
  223. package/components/_utils/locales/index.ts +0 -45
  224. package/components/_utils/locales/zh/common.json +0 -227
  225. package/components/_utils/locales/zh/index.ts +0 -6
  226. package/components/_utils/locales/zh/login.json +0 -96
  227. package/components/_utils/locales/zh/map.json +0 -4
  228. package/components/_utils/locales/zh/user.json +0 -82
  229. package/components/_utils/popupCenter.ts +0 -48
  230. package/components/assets/images/error.png +0 -0
  231. package/components/context/base.tsx +0 -28
  232. package/components/context/global/context.tsx +0 -39
  233. package/components/context/global/reducer.tsx +0 -56
  234. package/components/context/module/context.tsx +0 -23
  235. package/components/index.ts +0 -12
  236. package/config/antdReplacer.js +0 -51
  237. package/config/env.js +0 -104
  238. package/config/getHttpsConfig.js +0 -66
  239. package/config/jest/cssTransform.js +0 -14
  240. package/config/jest/fileTransform.js +0 -40
  241. package/config/modules.js +0 -134
  242. package/config/paths.js +0 -71
  243. package/config/pnpTs.js +0 -35
  244. package/config/webpack.config.js +0 -835
  245. package/config/webpackDevServer.config.js +0 -130
  246. package/examples.tsx +0 -82
  247. package/index.js +0 -1
  248. package/logo.svg +0 -7
  249. package/public/favicon.ico +0 -0
  250. package/public/index.html +0 -43
  251. package/public/logo192.png +0 -0
  252. package/public/logo512.png +0 -0
  253. package/public/manifest.json +0 -25
  254. package/public/robots.txt +0 -3
  255. package/react-app-env.d.ts +0 -71
  256. package/reportWebVitals.ts +0 -15
  257. package/scripts/build.js +0 -208
  258. package/scripts/lib.js +0 -200
  259. package/scripts/publish.js +0 -57
  260. package/scripts/start.js +0 -162
  261. package/scripts/test.js +0 -49
  262. package/setupTests.ts +0 -5
  263. package/tsconfig.json +0 -30
@@ -1,22 +0,0 @@
1
- import { getDefaultG2Config, IG2Config, IG2Events, IG2FCProps } from '../Type'
2
-
3
- export interface DownloadATConfig extends IG2Config {}
4
-
5
- const defaultConfig: DownloadATConfig = {
6
- ...getDefaultG2Config(),
7
- }
8
-
9
- export const getDefaultDownloadAuthenticatorConfig = (): DownloadATConfig => ({
10
- ...getDefaultG2Config(),
11
- ...defaultConfig,
12
- })
13
-
14
- export interface DownloadATEvents extends IG2Events {}
15
-
16
- export interface GuardDownloadATProps extends IG2FCProps, DownloadATEvents {
17
- config: Partial<DownloadATConfig>
18
- }
19
-
20
- export interface GuardDownloadATViewProps extends GuardDownloadATProps {
21
- config: DownloadATConfig
22
- }
@@ -1,52 +0,0 @@
1
- .g2-view-container-totp-dl {
2
- width: 900px;
3
- padding: 0;
4
- }
5
- .g2-mfa-totp-title {
6
- width: 100%;
7
- height: 54px;
8
- display: flex;
9
- align-items: center;
10
- justify-content: center;
11
- font-size: 16px;
12
- color: #293350;
13
- border-bottom: 1px solid #eaebee;
14
- margin-bottom: 54px;
15
- }
16
- .g2-mfa-totp-download-tabs {
17
- margin-top: 30px;
18
- }
19
-
20
- .g2-mfa-download-at-tab {
21
- display: flex;
22
- flex-direction: column;
23
- align-items: center;
24
- margin-top: 15px;
25
-
26
- .g2-mfa-totp-download-subtitle {
27
- color: #545968;
28
- }
29
-
30
- .g2-mfa-totp-download-qrcode-item {
31
- display: flex;
32
- flex-direction: column;
33
- align-items: center;
34
-
35
- margin-top: 35px;
36
-
37
- .g2-mfa-totp-download-image {
38
- width: 130px;
39
- height: 130px;
40
- display: flex;
41
- align-items: center;
42
- justify-content: center;
43
- box-shadow: 0px 0px 30px rgba(84, 89, 104, 0.15);
44
- border-radius: 4px;
45
- }
46
-
47
- .g2-mfa-totp-download-qrcode-text {
48
- margin-top: 8px;
49
- color: #545968;
50
- }
51
- }
52
- }
@@ -1,21 +0,0 @@
1
- import React from 'react'
2
- import { ImagePro } from '../ImagePro'
3
- import { GuardErrorViewProps } from './interface'
4
-
5
- import './styles.less'
6
-
7
- export const GuardErrorView: React.FC<GuardErrorViewProps> = (props) => {
8
- const messages = props?.initData?.messages
9
- ? `出错了~:${props?.initData?.messages} `
10
- : `未知的错误~ 请您联系管理员进行处理`
11
- const imgSrc = require('../assets/images/error.png').default
12
-
13
- return (
14
- <div className="g2-view-container">
15
- <div className="g2-error-content">
16
- <ImagePro width={240} height={162} src={imgSrc} alt="guard error img" />
17
- <span>{messages}</span>
18
- </div>
19
- </div>
20
- )
21
- }
@@ -1,9 +0,0 @@
1
- export interface ErrorInitData {
2
- messages?: string
3
- }
4
-
5
- export interface GuardErrorProps {
6
- initData?: ErrorInitData
7
- }
8
-
9
- export interface GuardErrorViewProps extends GuardErrorProps {}
@@ -1,12 +0,0 @@
1
- .g2-error-content {
2
- display: flex;
3
- flex-direction: column;
4
- align-items: center;
5
- margin: auto 0;
6
-
7
- span {
8
- margin-top: 33px;
9
- color: #545968;
10
- font-size: 14px;
11
- }
12
- }
@@ -1,162 +0,0 @@
1
- import React, { useRef, useState } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { Form, Input } from 'antd'
4
- import { StoreValue } from 'antd/lib/form/interface'
5
-
6
- import { UserOutlined, SafetyOutlined, LockOutlined } from '@ant-design/icons'
7
- import { SendCode } from '../../SendCode'
8
-
9
- import { useAuthClient } from '../../Guard/authClient'
10
- import { fieldRequiredRule, getPasswordValidate, validate } from '../../_utils'
11
- import SubmitButton from '../../SubmitButton'
12
-
13
- interface ResetPasswordProps {
14
- onReset: any
15
- publicConfig: any
16
- onSend: (type: 'email' | 'phone') => void
17
- onSendError: (type: 'email' | 'phone', error: any) => void
18
- }
19
- export const ResetPassword = (props: ResetPasswordProps) => {
20
- const { t } = useTranslation()
21
- let [form] = Form.useForm()
22
- let [identify, setIdentify] = useState('')
23
- let [codeMethod, setCodeMethod] = useState<'phone' | 'email'>('phone')
24
- let client = useAuthClient()
25
- let submitButtonRef = useRef<any>(null)
26
-
27
- const verifyCodeLength = props.publicConfig.verifyCodeLength ?? 4
28
-
29
- const onFinish = async (values: any) => {
30
- let identify = values.identify
31
- let code = values.code
32
- let newPassword = values.password
33
- let context = new Promise(() => {})
34
-
35
- if (codeMethod === 'email') {
36
- context = client.resetPasswordByEmailCode(identify, code, newPassword)
37
- }
38
- if (codeMethod === 'phone') {
39
- context = client.resetPasswordByPhoneCode(identify, code, newPassword)
40
- }
41
-
42
- context
43
- .then((r) => {
44
- props.onSend(codeMethod)
45
- props.onReset(r)
46
- })
47
- .catch((e) => {
48
- props.onSendError(codeMethod, e)
49
- props.onReset(e)
50
- })
51
- }
52
-
53
- return (
54
- <div className="authing-g2-login-phone-code">
55
- <Form
56
- name="resetPassword"
57
- form={form}
58
- onFinish={onFinish}
59
- onFinishFailed={() => {
60
- submitButtonRef?.current?.onError()
61
- }}
62
- autoComplete="off"
63
- >
64
- <Form.Item
65
- className="authing-g2-input-form"
66
- name="identify"
67
- validateFirst={true}
68
- rules={[
69
- ...fieldRequiredRule(t('common.account')),
70
- {
71
- validator: async (_, value: StoreValue) => {
72
- if (!value) {
73
- return
74
- }
75
- if (validate('email', value) || validate('phone', value)) {
76
- return
77
- } else {
78
- throw new Error(t('login.inputCorrectPhoneOrEmail'))
79
- }
80
- },
81
- },
82
- ]}
83
- >
84
- <Input
85
- className="authing-g2-input"
86
- autoComplete="tel"
87
- size="large"
88
- placeholder={t('login.inputPhoneOrEmail')}
89
- value={identify}
90
- onChange={(e) => {
91
- let v = e.target.value
92
- setIdentify(v)
93
- if (validate('email', v)) {
94
- setCodeMethod('email')
95
- }
96
- if (validate('phone', v)) {
97
- setCodeMethod('phone')
98
- }
99
- }}
100
- prefix={<UserOutlined style={{ color: '#878A95' }} />}
101
- />
102
- </Form.Item>
103
- <Form.Item
104
- className="authing-g2-input-form"
105
- name="code"
106
- rules={[...fieldRequiredRule(t('common.captchaCode'))]}
107
- >
108
- <SendCode
109
- className="authing-g2-input"
110
- autoComplete="one-time-code"
111
- size="large"
112
- placeholder={t('common.inputFourVerifyCode', {
113
- length: verifyCodeLength,
114
- })}
115
- prefix={<SafetyOutlined style={{ color: '#878A95' }} />}
116
- maxLength={verifyCodeLength}
117
- method={codeMethod}
118
- data={identify}
119
- onSendCodeBefore={async () => {
120
- await form.validateFields(['identify'])
121
- }}
122
-
123
- // form={form}
124
- />
125
- </Form.Item>
126
- <Form.Item
127
- className="authing-g2-input-form"
128
- name="password"
129
- validateFirst={true}
130
- rules={[
131
- {
132
- validator(_, value) {
133
- if ((value ?? '') && value.indexOf(' ') !== -1) {
134
- return Promise.reject(t('common.checkPasswordHasSpace'))
135
- }
136
- return Promise.resolve()
137
- },
138
- },
139
- ...getPasswordValidate(
140
- props.publicConfig?.passwordStrength,
141
- props.publicConfig?.customPasswordStrength
142
- ),
143
- ]}
144
- >
145
- <Input.Password
146
- className="authing-g2-input"
147
- size="large"
148
- placeholder={t('user.inputNewPwd')}
149
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
150
- />
151
- </Form.Item>
152
- <Form.Item className="authing-g2-input-form submit-form">
153
- <SubmitButton
154
- className="forget-password"
155
- text={t('common.confirm')}
156
- ref={submitButtonRef}
157
- />
158
- </Form.Item>
159
- </Form>
160
- </div>
161
- )
162
- }
@@ -1,78 +0,0 @@
1
- import React from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { message } from 'antd'
4
-
5
- import { GuardModuleType } from '../Guard/module'
6
- import { ResetPassword } from './core/resetPassword'
7
-
8
- import { ImagePro } from '../ImagePro'
9
- import { ForgetPasswordViewProps } from './interface'
10
- import { useAuthClient } from '../Guard/authClient'
11
- import { CommonMessage } from '..'
12
-
13
- export const GuardForgetPassword: React.FC<ForgetPasswordViewProps> = (
14
- props
15
- ) => {
16
- const { t } = useTranslation()
17
- let publicConfig = props.config.__publicConfig__
18
- const authClient = useAuthClient()
19
-
20
- const onReset = (res: any) => {
21
- let code = res.code
22
- if (code !== 200) {
23
- props.onPwdResetError?.(res, authClient)
24
- message.error(res.message)
25
- return
26
- }
27
- props.onPwdReset?.(authClient)
28
- // 返回登录
29
- const initData = {
30
- title: t('common.resetSuccess'),
31
- message: t('common.resetSuccessMessage'),
32
- }
33
- props.__changeModule?.(GuardModuleType.SUBMIT_SUCCESS, { ...initData })
34
- }
35
-
36
- const onSend = (type: 'phone' | 'email') => {
37
- if (type === 'phone') props.onPwdPhoneSend?.(authClient)
38
- if (type === 'email') props.onPwdEmailSend?.(authClient)
39
- }
40
- const onSendError = (type: 'phone' | 'email', error: any) => {
41
- if (type === 'phone')
42
- props.onPwdPhoneSendError?.(error as CommonMessage, authClient)
43
- if (type === 'email')
44
- props.onPwdEmailSendError?.(error as CommonMessage, authClient)
45
- }
46
-
47
- return (
48
- <div className="g2-view-container">
49
- <div className="g2-view-header">
50
- <ImagePro
51
- src={props.config?.logo}
52
- size={48}
53
- borderRadius={4}
54
- alt=""
55
- className="icon"
56
- />
57
- <div className="title">{t('login.resetPwd')}</div>
58
- <div className="title-explain">{t('user.resetpasswordText1')}</div>
59
- </div>
60
- <div className="g2-view-tabs">
61
- <ResetPassword
62
- onReset={onReset}
63
- publicConfig={publicConfig}
64
- onSend={onSend}
65
- onSendError={onSendError}
66
- />
67
- </div>
68
- <div className="g2-tips-line">
69
- <div
70
- className="link-like back-to-login"
71
- onClick={() => props.__changeModule?.(GuardModuleType.LOGIN)}
72
- >
73
- {t('common.backLoginPage')}
74
- </div>
75
- </div>
76
- </div>
77
- )
78
- }
@@ -1,32 +0,0 @@
1
- import { AuthenticationClient, CommonMessage } from '..'
2
- import { IG2Config, IG2Events, IG2FCProps, IG2FCViewProps } from '../Type'
3
-
4
- export interface ForgetPasswordEvents extends IG2Events {
5
- onPwdEmailSend?: (authClient: AuthenticationClient) => void
6
- onPwdEmailSendError?: (
7
- error: CommonMessage,
8
- authClient: AuthenticationClient
9
- ) => void
10
- onPwdPhoneSend?: (authClient: AuthenticationClient) => void
11
- onPwdPhoneSendError?: (
12
- error: CommonMessage,
13
- authClient: AuthenticationClient
14
- ) => void
15
- onPwdReset?: (authClient: AuthenticationClient) => void
16
- onPwdResetError?: (
17
- error: CommonMessage,
18
- authClient: AuthenticationClient
19
- ) => void
20
- }
21
-
22
- export interface ForgetPasswordConfig extends IG2Config {}
23
-
24
- export interface ForgetPasswordProps extends IG2FCProps, ForgetPasswordEvents {
25
- config: Partial<IG2Config>
26
- }
27
-
28
- export interface ForgetPasswordViewProps
29
- extends ForgetPasswordProps,
30
- IG2FCViewProps {
31
- config: IG2Config
32
- }
@@ -1,255 +0,0 @@
1
- import React, {
2
- useCallback,
3
- useEffect,
4
- useMemo,
5
- useReducer,
6
- useState,
7
- } from 'react'
8
- import { ConfigProvider, message, Modal } from 'antd'
9
-
10
- import { GuardLoginView } from '../Login'
11
-
12
- import { initAuthClient } from './authClient'
13
- import { GuardEvents, guardEventsFilter } from './event'
14
- import { initConfig } from '../_utils/config'
15
- import { insertStyles } from '../_utils'
16
- import { initGuardHttp } from '../_utils/guradHttp'
17
- import { initI18n } from '..//_utils/locales'
18
- import { IG2FCProps } from '../Type'
19
- import { getDefaultGuardLocalConfig, GuardLocalConfig } from './config'
20
- import { ShieldSpin } from '../ShieldSpin'
21
- import { GuardModuleType } from './module'
22
- import { GuardMFAView } from '../MFA'
23
- import { GuardRegisterView } from '../Register'
24
- import { GuardDownloadATView } from '../DownloadAuthenticator'
25
- import { GuardStateMachine, useHistoryHijack } from './stateMachine'
26
- import { GuardBindTotpView } from '../BindTotp'
27
- import { GuardForgetPassword } from '../ForgetPassword'
28
- import { GuardChangePassword } from '../ChangePassword'
29
- import { GuardNeedHelpView } from '../NeedHelpView'
30
- import { GuardCompleteInfoView } from '../CompleteInfo'
31
- import { GuardRecoveryCodeView } from '../RecoveryCode'
32
- import './styles.less'
33
- import { IconFont } from '../AuthingGuard/IconFont'
34
- import { GuardErrorView } from '../Error'
35
- import { GuardMode } from '..'
36
- import { GuardSubmitSuccessView } from '../SubmitSuccess'
37
-
38
- const PREFIX_CLS = 'authing-ant'
39
-
40
- message.config({
41
- prefixCls: `${PREFIX_CLS}-message`,
42
- })
43
-
44
- const ComponentsMapping: Record<
45
- GuardModuleType,
46
- (props: GuardViewProps) => React.ReactNode
47
- > = {
48
- [GuardModuleType.ERROR]: (props) => <GuardErrorView {...props} />,
49
- [GuardModuleType.LOGIN]: (props) => <GuardLoginView {...props} />,
50
- [GuardModuleType.MFA]: (props) => <GuardMFAView {...props} />,
51
- [GuardModuleType.REGISTER]: (props) => <GuardRegisterView {...props} />,
52
- [GuardModuleType.DOWNLOAD_AT]: (props) => <GuardDownloadATView {...props} />,
53
- [GuardModuleType.FORGET_PWD]: (props) => <GuardForgetPassword {...props} />,
54
- [GuardModuleType.CHANGE_PWD]: (props) => <GuardChangePassword {...props} />,
55
- [GuardModuleType.BIND_TOTP]: (props) => <GuardBindTotpView {...props} />,
56
- [GuardModuleType.ANY_QUESTIONS]: (props) => <GuardNeedHelpView {...props} />,
57
- [GuardModuleType.COMPLETE_INFO]: (props) => (
58
- <GuardCompleteInfoView {...props} />
59
- ),
60
- [GuardModuleType.RECOVERY_CODE]: (props) => (
61
- <GuardRecoveryCodeView {...props} />
62
- ),
63
- [GuardModuleType.SUBMIT_SUCCESS]: (props) => (
64
- <GuardSubmitSuccessView {...props} />
65
- ),
66
- }
67
-
68
- export interface GuardProps extends GuardEvents, IG2FCProps {
69
- tenantId?: string
70
- config?: Partial<GuardLocalConfig>
71
- visible?: boolean
72
- }
73
-
74
- interface GuardViewProps extends GuardProps {
75
- config: GuardLocalConfig
76
- initData: any
77
- }
78
-
79
- interface IBaseAction<T = string, P = any> {
80
- type: T & string
81
- payload?: Partial<P>
82
- }
83
-
84
- interface ModuleState {
85
- moduleName: GuardModuleType
86
- initData: any
87
- }
88
-
89
- export const Guard = (props: GuardProps) => {
90
- const { appId, tenantId, config } = props
91
- // 整合一下 所有的事件
92
- const events = guardEventsFilter(props)
93
-
94
- // 初始化 Loading 标识
95
- const [initSettingEnd, setInitSettingEnd] = useState(false)
96
-
97
- const [initError, setInitError] = useState(false)
98
- const [errorMessage, setErrorMessage] = useState('')
99
-
100
- // Config
101
- const [GuardLocalConfig, setGuardLocalConfig] = useState<GuardLocalConfig>(
102
- getDefaultGuardLocalConfig()
103
- )
104
-
105
- // 状态机
106
- const [
107
- guardStateMachine,
108
- setGuardStateMachine,
109
- ] = useState<GuardStateMachine>()
110
-
111
- // 劫持浏览器 History
112
- const [historyNext] = useHistoryHijack(guardStateMachine?.back)
113
-
114
- // 首页 init 数据
115
- const initState: ModuleState = {
116
- moduleName: GuardModuleType.LOGIN,
117
- initData: {},
118
- }
119
-
120
- // modules 定义
121
- const moduleReducer: (
122
- state: ModuleState,
123
- action: IBaseAction<GuardModuleType, ModuleState>
124
- ) => ModuleState = (state, { type, payload }) => {
125
- return {
126
- moduleName: type,
127
- initData: payload?.initData,
128
- }
129
- }
130
-
131
- // Modules Reducer
132
- const [moduleState, changeModule] = useReducer(moduleReducer, initState)
133
-
134
- // 切换 Module
135
- const onChangeModule = (moduleName: GuardModuleType, initData: any = {}) => {
136
- changeModule({
137
- type: moduleName,
138
- payload: {
139
- initData: initData ?? {},
140
- },
141
- })
142
- }
143
-
144
- // 初始化 Guard 一系列的东西
145
- const initGuardSetting = useCallback(async () => {
146
- try {
147
- // Rest 初始化
148
- const httpClient = initGuardHttp(
149
- config?.host ?? getDefaultGuardLocalConfig().host
150
- )
151
- httpClient.setAppId(appId)
152
- tenantId && httpClient.setTenantId(tenantId)
153
-
154
- // Config 初始化
155
- const { config: mergedConfig, publicConfig } = await initConfig(
156
- appId,
157
- config ?? {},
158
- getDefaultGuardLocalConfig()
159
- )
160
-
161
- httpClient.setUserpoolId(publicConfig.userPoolId)
162
- setGuardLocalConfig(mergedConfig)
163
-
164
- // TODO 国际化 这部分有点小问题 等待优化
165
- initI18n({}, mergedConfig.lang)
166
-
167
- // Authing JS SDK
168
- const authClient = initAuthClient(mergedConfig, appId, tenantId)
169
-
170
- events?.onLoad?.(authClient)
171
-
172
- // 状态机 初始化
173
- const guardStateMachine = new GuardStateMachine(onChangeModule, initState)
174
- guardStateMachine.setConfig(mergedConfig)
175
- setGuardStateMachine(guardStateMachine)
176
- } catch (error: any) {
177
- events?.onLoadError?.(error)
178
-
179
- setErrorMessage(error.message)
180
- setInitError(true)
181
-
182
- console.error(error)
183
- } finally {
184
- // 初始化 结束
185
- setInitSettingEnd(true)
186
- }
187
- // eslint-disable-next-line react-hooks/exhaustive-deps
188
- }, [])
189
-
190
- useEffect(() => {
191
- initGuardSetting()
192
- console.log('useEffect')
193
- }, [initGuardSetting])
194
-
195
- useEffect(() => {
196
- insertStyles(GuardLocalConfig.contentCss)
197
- }, [GuardLocalConfig.contentCss])
198
-
199
- const renderModule = useMemo(() => {
200
- if (initSettingEnd) {
201
- if (initError)
202
- return <GuardErrorView initData={{ messages: errorMessage }} />
203
- return ComponentsMapping[moduleState.moduleName]({
204
- appId,
205
- initData: moduleState.initData,
206
- config: GuardLocalConfig,
207
- ...events,
208
- __changeModule: (moduleName, initData) => {
209
- historyNext(initData)
210
- guardStateMachine?.next(moduleName, initData)
211
- },
212
- })
213
- } else {
214
- return (
215
- <div className="g2-init-setting-loading">
216
- <ShieldSpin size={100} />
217
- </div>
218
- )
219
- }
220
- }, [
221
- appId,
222
- errorMessage,
223
- events,
224
- GuardLocalConfig,
225
- guardStateMachine,
226
- historyNext,
227
- initError,
228
- initSettingEnd,
229
- moduleState.initData,
230
- moduleState.moduleName,
231
- ])
232
-
233
- return (
234
- // TODO 这部分缺失 Loging 态
235
- <ConfigProvider prefixCls={PREFIX_CLS}>
236
- {config?.mode === GuardMode.Modal ? (
237
- <Modal
238
- className="authing-g2-render-module-modal"
239
- closeIcon={
240
- <IconFont type="authing-close-line" className="g2-modal-close" />
241
- }
242
- visible={props.visible}
243
- onCancel={props.onClose}
244
- keyboard={config.escCloseable}
245
- maskClosable={false} //点击蒙层,是否允许关闭
246
- getContainer={config.target ? config.target : false}
247
- >
248
- <div className="authing-g2-render-module">{renderModule}</div>
249
- </Modal>
250
- ) : (
251
- <div className="authing-g2-render-module">{renderModule}</div>
252
- )}
253
- </ConfigProvider>
254
- )
255
- }
@@ -1,46 +0,0 @@
1
- import { AuthenticationClient } from 'authing-js-sdk'
2
-
3
- import packageConfig from '../../package.json'
4
- import { GuardLocalConfig } from './config'
5
-
6
- let authClient: AuthenticationClient
7
-
8
- export const initAuthClient = (
9
- config: GuardLocalConfig,
10
- appId: string,
11
- tenantId?: string
12
- ) => {
13
- const host = config.__appHost__ ?? config.host
14
- const lang = config.lang
15
-
16
- if (!authClient) {
17
- try {
18
- authClient = new AuthenticationClient({
19
- appHost: host,
20
- tenantId: tenantId,
21
- appId,
22
- lang,
23
- requestFrom: `Guard-${packageConfig.framework}@${packageConfig.version}`,
24
- onError: (code, msg: any) => {
25
- // if ([].includes(code)) message.error(msg)
26
-
27
- console.error(code, msg)
28
- },
29
- })
30
- } catch (error) {
31
- throw error
32
- }
33
- }
34
-
35
- return authClient
36
- }
37
-
38
- export const getAuthClient = () => {
39
- if (!authClient) {
40
- throw new Error('Please initialize AuthClient')
41
- }
42
-
43
- return authClient
44
- }
45
-
46
- export const useAuthClient = () => getAuthClient()