@authing/react-ui-components 3.0.0-alpha → 3.0.0-rc.11

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 (235) hide show
  1. package/dist/index.min.css +2 -0
  2. package/dist/index.min.js +2 -0
  3. package/dist/index.min.js.LICENSE.txt +71 -0
  4. package/{components/ShieldSpin/loading.svg → dist/static/media/loading.4a67a5f3.svg} +0 -0
  5. package/lib/index.d.ts +2108 -118
  6. package/lib/index.min.css +2 -2
  7. package/lib/index.min.js +1 -1
  8. package/lib/index.min.js.LICENSE.txt +2 -0
  9. package/package.json +32 -10
  10. package/.eslintignore +0 -6
  11. package/.eslintrc.js +0 -7
  12. package/.prettierrc +0 -5
  13. package/.vscode/settings.json +0 -31
  14. package/build/favicon.ico +0 -0
  15. package/build/logo192.png +0 -0
  16. package/build/logo512.png +0 -0
  17. package/build/manifest.json +0 -25
  18. package/build/robots.txt +0 -3
  19. package/components/AuthingDropdown/index.tsx +0 -52
  20. package/components/AuthingDropdown/style.less +0 -43
  21. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  22. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  23. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  24. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  25. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  26. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  27. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  28. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  29. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  30. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  31. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  32. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  33. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  34. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  35. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  36. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  37. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  38. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  39. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  40. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  41. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  42. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  43. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  44. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  45. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  46. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  47. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  48. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  49. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  50. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  51. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  52. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  53. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  54. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  55. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  56. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  57. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  58. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  59. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  60. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  61. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  62. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  63. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  64. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  65. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  66. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  67. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  68. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  69. package/components/AuthingGuard/Forms/index.ts +0 -13
  70. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  71. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  72. package/components/AuthingGuard/Header/index.tsx +0 -25
  73. package/components/AuthingGuard/Header/style.less +0 -52
  74. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  75. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  76. package/components/AuthingGuard/IconFont/style.less +0 -6
  77. package/components/AuthingGuard/IconFont/svg.js +0 -2
  78. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  79. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  80. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  81. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  82. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  83. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  84. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  85. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  86. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  87. package/components/AuthingGuard/api/appConfig.ts +0 -146
  88. package/components/AuthingGuard/api/index.ts +0 -3
  89. package/components/AuthingGuard/api/sso.ts +0 -29
  90. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  91. package/components/AuthingGuard/constants.ts +0 -105
  92. package/components/AuthingGuard/hooks/index.tsx +0 -70
  93. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  94. package/components/AuthingGuard/index.tsx +0 -126
  95. package/components/AuthingGuard/style.less +0 -103
  96. package/components/AuthingGuard/types/Forms.ts +0 -94
  97. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  98. package/components/AuthingGuard/types/GuardState.ts +0 -7
  99. package/components/AuthingGuard/types/Locales.ts +0 -12
  100. package/components/AuthingGuard/types/index.ts +0 -4
  101. package/components/AuthingTabs/index.tsx +0 -98
  102. package/components/AuthingTabs/style.less +0 -135
  103. package/components/BindTotp/core/bindSuccess.tsx +0 -61
  104. package/components/BindTotp/core/securityCode.tsx +0 -119
  105. package/components/BindTotp/index.tsx +0 -134
  106. package/components/BindTotp/props.ts +0 -30
  107. package/components/BindTotp/styles.less +0 -56
  108. package/components/ChangeLanguage/index.tsx +0 -35
  109. package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
  110. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  111. package/components/ChangePassword/index.tsx +0 -59
  112. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  113. package/components/CompleteInfo/index.tsx +0 -45
  114. package/components/CompleteInfo/props.ts +0 -40
  115. package/components/CompleteInfo/styles.less +0 -7
  116. package/components/CompleteUserInfo/index.tsx +0 -49
  117. package/components/CompleteUserInfo/props.ts +0 -25
  118. package/components/ComponentsRender/index.back +0 -64
  119. package/components/CopyAbleText/index.tsx +0 -54
  120. package/components/CopyAbleText/style.less +0 -13
  121. package/components/DownloadAuthenticator/index.tsx +0 -97
  122. package/components/DownloadAuthenticator/props.ts +0 -22
  123. package/components/DownloadAuthenticator/styles.less +0 -52
  124. package/components/ForgetPassword/core/resetPassword.tsx +0 -150
  125. package/components/ForgetPassword/index.tsx +0 -51
  126. package/components/Guard/Guard.tsx +0 -226
  127. package/components/Guard/authClient.ts +0 -55
  128. package/components/Guard/config.ts +0 -19
  129. package/components/Guard/event.ts +0 -18
  130. package/components/Guard/index.tsx +0 -10
  131. package/components/Guard/module.ts +0 -19
  132. package/components/Guard/stateMachine.ts +0 -133
  133. package/components/Guard/styles.less +0 -444
  134. package/components/IconFont/iconfont.js +0 -74
  135. package/components/IconFont/index.tsx +0 -16
  136. package/components/IconFont/style.less +0 -6
  137. package/components/IconFont/svg.js +0 -2
  138. package/components/ImagePro/index.tsx +0 -52
  139. package/components/ImagePro/styles.less +0 -40
  140. package/components/Login/codemap.ts +0 -35
  141. package/components/Login/core/withAD.tsx +0 -9
  142. package/components/Login/core/withAppQrcode.tsx +0 -49
  143. package/components/Login/core/withLDAP.tsx +0 -145
  144. package/components/Login/core/withPassword.tsx +0 -176
  145. package/components/Login/core/withPhonecode.tsx +0 -135
  146. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  147. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  148. package/components/Login/index.tsx +0 -359
  149. package/components/Login/props.ts +0 -90
  150. package/components/Login/socialLogin/index.tsx +0 -413
  151. package/components/Login/socialLogin/style.less +0 -61
  152. package/components/Login/styles.less +0 -53
  153. package/components/MFA/codemap.ts +0 -21
  154. package/components/MFA/core/email.tsx +0 -226
  155. package/components/MFA/core/face.tsx +0 -297
  156. package/components/MFA/core/face_deps.tsx +0 -37
  157. package/components/MFA/core/sms.tsx +0 -222
  158. package/components/MFA/core/totp.tsx +0 -137
  159. package/components/MFA/index.tsx +0 -135
  160. package/components/MFA/mfaMethods/index.tsx +0 -81
  161. package/components/MFA/mfaMethods/style.less +0 -39
  162. package/components/MFA/props.ts +0 -51
  163. package/components/MFA/styles.less +0 -92
  164. package/components/NeedHelpView/core/describeQuestions.tsx +0 -227
  165. package/components/NeedHelpView/index.tsx +0 -99
  166. package/components/RecoveryCode/core/useCode.tsx +0 -71
  167. package/components/RecoveryCode/index.tsx +0 -27
  168. package/components/RecoveryCode/interface.ts +0 -31
  169. package/components/RecoveryCode/style.less +0 -13
  170. package/components/Register/codemap.ts +0 -16
  171. package/components/Register/components/Agreements/index.tsx +0 -81
  172. package/components/Register/components/Agreements/style.less +0 -44
  173. package/components/Register/core/WithEmail.tsx +0 -250
  174. package/components/Register/core/WithPhone.tsx +0 -190
  175. package/components/Register/index.tsx +0 -122
  176. package/components/Register/props.ts +0 -50
  177. package/components/SendCode/SendCodeBtn.tsx +0 -96
  178. package/components/SendCode/index.tsx +0 -98
  179. package/components/SendCode/style.less +0 -31
  180. package/components/ShieldSpin/index.tsx +0 -27
  181. package/components/SubmitButton/index.tsx +0 -50
  182. package/components/Type/index.ts +0 -61
  183. package/components/VerifyCodeInput/index.tsx +0 -76
  184. package/components/VerifyCodeInput/style.less +0 -24
  185. package/components/_utils/GuardErrorCode.ts +0 -8
  186. package/components/_utils/clipboard.ts +0 -27
  187. package/components/_utils/config.ts +0 -123
  188. package/components/_utils/guradHttp.ts +0 -93
  189. package/components/_utils/hooks/index.ts +0 -56
  190. package/components/_utils/http.ts +0 -85
  191. package/components/_utils/index.ts +0 -310
  192. package/components/_utils/locales/en/common.json +0 -218
  193. package/components/_utils/locales/en/index.ts +0 -6
  194. package/components/_utils/locales/en/login.json +0 -95
  195. package/components/_utils/locales/en/map.json +0 -4
  196. package/components/_utils/locales/en/user.json +0 -82
  197. package/components/_utils/locales/index.ts +0 -45
  198. package/components/_utils/locales/zh/common.json +0 -218
  199. package/components/_utils/locales/zh/index.ts +0 -6
  200. package/components/_utils/locales/zh/login.json +0 -95
  201. package/components/_utils/locales/zh/map.json +0 -4
  202. package/components/_utils/locales/zh/user.json +0 -82
  203. package/components/_utils/popupCenter.ts +0 -48
  204. package/components/context/base.tsx +0 -28
  205. package/components/context/global/context.tsx +0 -39
  206. package/components/context/global/reducer.tsx +0 -56
  207. package/components/context/module/context.tsx +0 -23
  208. package/components/index.ts +0 -10
  209. package/config/antdReplacer.js +0 -51
  210. package/config/env.js +0 -104
  211. package/config/getHttpsConfig.js +0 -66
  212. package/config/jest/cssTransform.js +0 -14
  213. package/config/jest/fileTransform.js +0 -40
  214. package/config/modules.js +0 -134
  215. package/config/paths.js +0 -71
  216. package/config/pnpTs.js +0 -35
  217. package/config/webpack.config.js +0 -835
  218. package/config/webpackDevServer.config.js +0 -130
  219. package/examples.tsx +0 -100
  220. package/index.js +0 -1
  221. package/logo.svg +0 -7
  222. package/public/favicon.ico +0 -0
  223. package/public/index.html +0 -43
  224. package/public/logo192.png +0 -0
  225. package/public/logo512.png +0 -0
  226. package/public/manifest.json +0 -25
  227. package/public/robots.txt +0 -3
  228. package/react-app-env.d.ts +0 -71
  229. package/reportWebVitals.ts +0 -15
  230. package/scripts/build.js +0 -208
  231. package/scripts/lib.js +0 -200
  232. package/scripts/start.js +0 -162
  233. package/scripts/test.js +0 -49
  234. package/setupTests.ts +0 -5
  235. package/tsconfig.json +0 -30
@@ -1,61 +0,0 @@
1
- import { Form, Checkbox, Typography } from 'antd'
2
- import React, { useRef } from 'react'
3
- import { useTranslation } from 'react-i18next'
4
- import SubmitButton from '../../SubmitButton'
5
-
6
- const { Paragraph } = Typography
7
-
8
- export interface BindSuccessProps {
9
- onBind: any
10
- secret: string
11
- }
12
-
13
- export const BindSuccess: React.FC<BindSuccessProps> = ({ secret, onBind }) => {
14
- // const [isSaved, setIsSaved] = useState(false)
15
- const submitButtonRef = useRef<any>(null)
16
- const [form] = Form.useForm()
17
-
18
- const { t } = useTranslation()
19
-
20
- const bindSuccess = async () => {
21
- submitButtonRef.current?.onSpin(true)
22
- try {
23
- await form.validateFields()
24
- submitButtonRef.current?.onSpin(true)
25
- onBind()
26
- } finally {
27
- submitButtonRef.current?.onSpin(true)
28
- }
29
- }
30
-
31
- return (
32
- <>
33
- <p className="authing-g2-mfa-title">{t('common.totpText1')}</p>
34
- <p className="authing-g2-mfa-tips">{t('common.totpText2')}</p>
35
-
36
- <div className="g2-mfa-bindTotp-copySecret">
37
- <Paragraph copyable>{secret}</Paragraph>
38
- </div>
39
-
40
- <Form form={form} onFinish={bindSuccess} style={{ width: '100%' }}>
41
- <Form.Item
42
- className="authing-g2-input-form"
43
- name="remember"
44
- rules={[
45
- {
46
- required: true,
47
- message: t('common.pleaseRecordKey'),
48
- },
49
- ]}
50
- valuePropName="checked"
51
- >
52
- <Checkbox className="g2-mfa-bindTotp-secretSave">
53
- {t('login.rememberedSecret')}
54
- </Checkbox>
55
- </Form.Item>
56
-
57
- <SubmitButton text={t('common.bindSuccess')} ref={submitButtonRef} />
58
- </Form>
59
- </>
60
- )
61
- }
@@ -1,119 +0,0 @@
1
- import { Form, message } from 'antd'
2
- import React, { useRef, useState } from 'react'
3
- import { useTranslation } from 'react-i18next'
4
- import { useAsyncFn } from 'react-use'
5
- import { VerifyCodeInput } from '../../VerifyCodeInput'
6
- import { GuardModuleType } from '../../Guard/module'
7
- import { useGuardHttp } from '../../_utils/guradHttp'
8
- import SubmitButton from '../../SubmitButton'
9
-
10
- const CODE_LEN = 6
11
- export interface SecurityCodeProps {
12
- mfaToken: string
13
- qrcode: string
14
- onNext: any
15
- changeModule: any
16
- }
17
-
18
- export const SecurityCode: React.FC<SecurityCodeProps> = ({
19
- mfaToken,
20
- qrcode,
21
- onNext,
22
- changeModule,
23
- }) => {
24
- const [form] = Form.useForm()
25
- const [saftyCode, setSaftyCode] = useState(new Array(CODE_LEN).fill(''))
26
- const submitButtonRef = useRef<any>(null)
27
-
28
- const { t } = useTranslation()
29
-
30
- const { post } = useGuardHttp()
31
-
32
- const onJump = () => {
33
- changeModule?.(GuardModuleType.DOWNLOAD_AT)
34
- }
35
-
36
- const [, bindTotp] = useAsyncFn(async () => {
37
- submitButtonRef.current.onSpin(true)
38
- try {
39
- const { code, data, message: resMessage } = await post(
40
- '/api/v2/mfa/totp/associate/confirm',
41
- {
42
- authenticator_type: 'totp',
43
- totp: saftyCode.join(''),
44
- source: 'APPLICATION',
45
- },
46
- {
47
- headers: {
48
- authorization: mfaToken,
49
- },
50
- }
51
- )
52
-
53
- if (code !== 200) {
54
- message.error(resMessage)
55
- } else {
56
- onNext(data)
57
- }
58
- } finally {
59
- submitButtonRef.current?.onSpin(false)
60
- }
61
- }, [mfaToken, saftyCode])
62
-
63
- return (
64
- <>
65
- <p className="authing-g2-mfa-title">{t('user.mfaBind')}</p>
66
- <p
67
- className="authing-g2-mfa-tips"
68
- style={{
69
- textAlign: 'left',
70
- }}
71
- >
72
- {t('common.usePhoneOpen')} Google Authenticator / Microsoft
73
- Authenticator({t('common.noValidator')}{' '}
74
- <span
75
- style={{
76
- color: '#396AFF',
77
- cursor: 'pointer',
78
- }}
79
- onClick={onJump}
80
- >
81
- {t('common.clickTodownload')}
82
- </span>
83
- ) {t('common.mfaText1')}
84
- </p>
85
- <img className="g2-mfa-bindTotp-qrcode" src={qrcode} alt="qrcode" />
86
- <Form
87
- className="g2-mfa-bindTotp-securityCode-form"
88
- form={form}
89
- onSubmitCapture={() => {}}
90
- onFinish={bindTotp}
91
- >
92
- <Form.Item
93
- name="mfaCode"
94
- className="g2-mfa-totp-verify-input"
95
- rules={[
96
- {
97
- validateTrigger: [],
98
- validator(r, v, cb) {
99
- if (saftyCode.some((item) => !item)) {
100
- cb(t('login.inputFullMfaCode'))
101
- return
102
- }
103
- cb()
104
- },
105
- },
106
- ]}
107
- >
108
- <VerifyCodeInput
109
- length={CODE_LEN}
110
- verifyCode={saftyCode}
111
- setVerifyCode={setSaftyCode}
112
- />
113
- </Form.Item>
114
- <p>{t('user.numberSafteyCode')}</p>
115
- <SubmitButton text={t('user.nextStep')} ref={submitButtonRef} />
116
- </Form>
117
- </>
118
- )
119
- }
@@ -1,134 +0,0 @@
1
- import { message } from 'antd'
2
- import { User } from 'authing-js-sdk'
3
- import React, { useEffect, useMemo, useState } from 'react'
4
- import { useAsyncFn } from 'react-use'
5
- import { ErrorCode } from '../_utils/GuardErrorCode'
6
- import { useGuardHttp } from '../_utils/guradHttp'
7
- import { useAuthClient } from '../Guard/authClient'
8
- import { GuardModuleType } from '../Guard/module'
9
- import { IconFont } from '../IconFont'
10
- import { ShieldSpin, Spin } from '../ShieldSpin'
11
- import { BindSuccess } from './core/bindSuccess'
12
- import { SecurityCode } from './core/securityCode'
13
- import { GuardBindTotpViewProps } from './props'
14
- import { useTranslation } from 'react-i18next'
15
- import './styles.less'
16
- const window: Window = require('global/window')
17
-
18
- enum BindTotpType {
19
- SECURITY_CODE = 'securityCode',
20
- BIND_SUCCESS = 'bindSuccess',
21
- }
22
-
23
- export const GuardBindTotpView: React.FC<GuardBindTotpViewProps> = ({
24
- config: GuardConfig,
25
- initData,
26
- onLogin,
27
- __changeModule,
28
- }) => {
29
- const { get, post } = useGuardHttp()
30
- const { t } = useTranslation()
31
- const [secret, setSecret] = useState('')
32
- const [qrcode, setQrcode] = useState('')
33
- const [user, setUser] = useState<User>()
34
- const [bindTotpType, setBindTotpType] = useState<BindTotpType>(
35
- BindTotpType.SECURITY_CODE
36
- )
37
-
38
- const authClient = useAuthClient()
39
-
40
- const [bindInfo, fetchBindInfo] = useAsyncFn(async () => {
41
- const query = {
42
- type: 'totp',
43
- source: 'APPLICATION',
44
- }
45
- const config = {
46
- headers: {
47
- authorization: initData.mfaToken,
48
- },
49
- }
50
-
51
- try {
52
- const { data } = await get<any>(
53
- `/api/v2/mfa/authenticator`,
54
- query,
55
- config
56
- )
57
-
58
- if (data.code === ErrorCode.LOGIN_INVALID) {
59
- message.error(data.message)
60
- __changeModule?.(GuardModuleType.LOGIN, {})
61
- return
62
- }
63
- } catch (error: any) {
64
- message.error(error?.message)
65
- }
66
-
67
- const { data } = await post<any>(
68
- '/api/v2/mfa/totp/associate',
69
- query,
70
- config
71
- )
72
-
73
- setSecret(data.recovery_code)
74
- setQrcode(data.qrcode_data_url)
75
- }, [initData.mfaToken])
76
-
77
- const onBind = () => {
78
- if (user) onLogin?.(user, authClient)
79
- }
80
-
81
- const onNext = (user: User) => {
82
- setUser(user)
83
- setBindTotpType(BindTotpType.BIND_SUCCESS)
84
- }
85
-
86
- useEffect(() => {
87
- fetchBindInfo()
88
- }, [fetchBindInfo])
89
-
90
- const renderContent = useMemo<
91
- Record<BindTotpType, (props: any) => React.ReactNode>
92
- >(
93
- () => ({
94
- [BindTotpType.SECURITY_CODE]: (props) => <SecurityCode {...props} />,
95
- [BindTotpType.BIND_SUCCESS]: (props) => <BindSuccess {...props} />,
96
- }),
97
- []
98
- )
99
-
100
- const onBack = () => {
101
- window.history.back()
102
- }
103
-
104
- return (
105
- <>
106
- {bindInfo.loading ? (
107
- <Spin />
108
- ) : (
109
- <div className="g2-view-container">
110
- <div className="g2-view-back">
111
- <span onClick={onBack}>
112
- <IconFont type="authing-back" />
113
- <span>{t('common.backToVerify')}</span>
114
- </span>
115
- </div>
116
- <div className="g2-mfa-content g2-mfa-bindTotp">
117
- {bindInfo.loading ? (
118
- <ShieldSpin />
119
- ) : (
120
- renderContent[bindTotpType]({
121
- mfaToken: initData.mfaToken,
122
- qrcode,
123
- secret,
124
- onBind,
125
- onNext,
126
- changeModule: __changeModule,
127
- })
128
- )}
129
- </div>
130
- </div>
131
- )}
132
- </>
133
- )
134
- }
@@ -1,30 +0,0 @@
1
- import { getDefaultG2Config, IG2Config, IG2Events, IG2FCProps } from '../Type'
2
- import { AuthenticationClient, User } from '..'
3
- import { GuardMFAInitData } from '../MFA/props'
4
-
5
- export interface BindTotpConfig extends IG2Config {}
6
-
7
- const defaultConfig: BindTotpConfig = {
8
- ...getDefaultG2Config(),
9
- }
10
-
11
- export const getDefaultMFAConfig = (): BindTotpConfig => ({
12
- ...getDefaultG2Config(),
13
- ...defaultConfig,
14
- })
15
-
16
- export interface BindTotpEvents extends IG2Events {
17
- onLogin?: (user: User, authClient: AuthenticationClient) => void
18
- }
19
-
20
- export interface GuardBindTotpInitData extends GuardMFAInitData {}
21
-
22
- export interface GuardBindTotpProps extends IG2FCProps, BindTotpEvents {
23
- config: Partial<BindTotpConfig>
24
- initData: GuardBindTotpInitData
25
- }
26
-
27
- export interface GuardBindTotpViewProps extends GuardBindTotpProps {
28
- config: BindTotpConfig
29
- initData: GuardBindTotpInitData
30
- }
@@ -1,56 +0,0 @@
1
- .g2-mfa-bindTotp {
2
- display: flex;
3
- flex-direction: column;
4
- align-items: center;
5
- height: 100%;
6
-
7
- .g2-mfa-bindTotp-copySecret {
8
- width: 100%;
9
- height: 48px;
10
- display: flex;
11
- justify-content: center;
12
- align-items: center;
13
- background: #f5f6f7;
14
- border-radius: 4px;
15
-
16
- .authing-ant-typography {
17
- margin: 0;
18
-
19
- svg {
20
- color: #878a95 !important;
21
- margin-left: 30px;
22
- }
23
- }
24
- }
25
- .g2-mfa-bindTotp-secretSave {
26
- margin-top: 16px;
27
- }
28
-
29
- .g2-mfa-submit-button {
30
- margin-top: 80px !important;
31
- }
32
-
33
- .g2-mfa-bindTotp-qrcode {
34
- box-shadow: 0px 0px 30px rgba(84, 89, 104, 0.15);
35
- border-radius: 4px;
36
- }
37
-
38
- .g2-mfa-bindTotp-securityCode-form {
39
- display: flex;
40
- flex-direction: column;
41
- align-items: center;
42
-
43
- .g2-mfa-submit-button {
44
- margin-top: 64px !important;
45
- }
46
-
47
- .g2-mfa-totp-verify-input {
48
- margin-bottom: 8px !important;
49
- margin-top: 40px !important;
50
- }
51
-
52
- p {
53
- color: #878a95;
54
- }
55
- }
56
- }
@@ -1,35 +0,0 @@
1
- import React from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { IconFont } from '../IconFont'
4
- import { changeLang } from '../_utils/locales'
5
-
6
- export const ChangeLanguage = (props: any) => {
7
- const { i18n } = useTranslation()
8
- if (props.langRange.length <= 1) {
9
- return <></>
10
- }
11
-
12
- let switchText = 'English'
13
- if (i18n.language === 'en-US') {
14
- switchText = '简体中文'
15
- }
16
- return (
17
- <div className="g2-change-language-container">
18
- <span
19
- className="g2-change-language-button"
20
- onClick={() => {
21
- if (i18n.language === 'zh-CN') {
22
- changeLang('en-US')
23
- props.onLangChange('en-US')
24
- } else if (i18n.language === 'en-US') {
25
- changeLang('zh-CN')
26
- props.onLangChange('zh-CN')
27
- }
28
- }}
29
- >
30
- <IconFont type="authing-global-line" />
31
- <span className="g2-change-language-text">{switchText}</span>
32
- </span>
33
- </div>
34
- )
35
- }
@@ -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
- }