@authing/react-ui-components 3.0.0-alpha → 3.0.0-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 (232) hide show
  1. package/lib/index.d.ts +781 -110
  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 +34 -12
  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/favicon.ico +0 -0
  11. package/build/logo192.png +0 -0
  12. package/build/logo512.png +0 -0
  13. package/build/manifest.json +0 -25
  14. package/build/robots.txt +0 -3
  15. package/components/AuthingDropdown/index.tsx +0 -52
  16. package/components/AuthingDropdown/style.less +0 -43
  17. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  18. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  19. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  20. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  21. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  22. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  23. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  24. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  25. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  26. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  27. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  28. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  29. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  30. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  31. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  32. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  33. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  34. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  35. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  36. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  37. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  38. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  39. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  40. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  41. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  42. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  43. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  44. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  45. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  46. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  47. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  48. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  49. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  50. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  51. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  52. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  53. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  54. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  55. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  56. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  57. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  58. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  59. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  60. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  61. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  62. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  63. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  64. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  65. package/components/AuthingGuard/Forms/index.ts +0 -13
  66. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  67. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  68. package/components/AuthingGuard/Header/index.tsx +0 -25
  69. package/components/AuthingGuard/Header/style.less +0 -52
  70. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  71. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  72. package/components/AuthingGuard/IconFont/style.less +0 -6
  73. package/components/AuthingGuard/IconFont/svg.js +0 -2
  74. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  75. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  76. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  77. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  78. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  79. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  80. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  81. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  82. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  83. package/components/AuthingGuard/api/appConfig.ts +0 -146
  84. package/components/AuthingGuard/api/index.ts +0 -3
  85. package/components/AuthingGuard/api/sso.ts +0 -29
  86. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  87. package/components/AuthingGuard/constants.ts +0 -105
  88. package/components/AuthingGuard/hooks/index.tsx +0 -70
  89. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  90. package/components/AuthingGuard/index.tsx +0 -126
  91. package/components/AuthingGuard/style.less +0 -103
  92. package/components/AuthingGuard/types/Forms.ts +0 -94
  93. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  94. package/components/AuthingGuard/types/GuardState.ts +0 -7
  95. package/components/AuthingGuard/types/Locales.ts +0 -12
  96. package/components/AuthingGuard/types/index.ts +0 -4
  97. package/components/AuthingTabs/index.tsx +0 -98
  98. package/components/AuthingTabs/style.less +0 -135
  99. package/components/BindTotp/core/bindSuccess.tsx +0 -61
  100. package/components/BindTotp/core/securityCode.tsx +0 -119
  101. package/components/BindTotp/index.tsx +0 -134
  102. package/components/BindTotp/props.ts +0 -30
  103. package/components/BindTotp/styles.less +0 -56
  104. package/components/ChangeLanguage/index.tsx +0 -35
  105. package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
  106. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  107. package/components/ChangePassword/index.tsx +0 -59
  108. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  109. package/components/CompleteInfo/index.tsx +0 -45
  110. package/components/CompleteInfo/props.ts +0 -40
  111. package/components/CompleteInfo/styles.less +0 -7
  112. package/components/CompleteUserInfo/index.tsx +0 -49
  113. package/components/CompleteUserInfo/props.ts +0 -25
  114. package/components/ComponentsRender/index.back +0 -64
  115. package/components/CopyAbleText/index.tsx +0 -54
  116. package/components/CopyAbleText/style.less +0 -13
  117. package/components/DownloadAuthenticator/index.tsx +0 -97
  118. package/components/DownloadAuthenticator/props.ts +0 -22
  119. package/components/DownloadAuthenticator/styles.less +0 -52
  120. package/components/ForgetPassword/core/resetPassword.tsx +0 -150
  121. package/components/ForgetPassword/index.tsx +0 -51
  122. package/components/Guard/Guard.tsx +0 -226
  123. package/components/Guard/authClient.ts +0 -55
  124. package/components/Guard/config.ts +0 -19
  125. package/components/Guard/event.ts +0 -18
  126. package/components/Guard/index.tsx +0 -10
  127. package/components/Guard/module.ts +0 -19
  128. package/components/Guard/stateMachine.ts +0 -133
  129. package/components/Guard/styles.less +0 -444
  130. package/components/IconFont/iconfont.js +0 -74
  131. package/components/IconFont/index.tsx +0 -16
  132. package/components/IconFont/style.less +0 -6
  133. package/components/IconFont/svg.js +0 -2
  134. package/components/ImagePro/index.tsx +0 -52
  135. package/components/ImagePro/styles.less +0 -40
  136. package/components/Login/codemap.ts +0 -35
  137. package/components/Login/core/withAD.tsx +0 -9
  138. package/components/Login/core/withAppQrcode.tsx +0 -49
  139. package/components/Login/core/withLDAP.tsx +0 -145
  140. package/components/Login/core/withPassword.tsx +0 -176
  141. package/components/Login/core/withPhonecode.tsx +0 -135
  142. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  143. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  144. package/components/Login/index.tsx +0 -359
  145. package/components/Login/props.ts +0 -90
  146. package/components/Login/socialLogin/index.tsx +0 -413
  147. package/components/Login/socialLogin/style.less +0 -61
  148. package/components/Login/styles.less +0 -53
  149. package/components/MFA/codemap.ts +0 -21
  150. package/components/MFA/core/email.tsx +0 -226
  151. package/components/MFA/core/face.tsx +0 -297
  152. package/components/MFA/core/face_deps.tsx +0 -37
  153. package/components/MFA/core/sms.tsx +0 -222
  154. package/components/MFA/core/totp.tsx +0 -137
  155. package/components/MFA/index.tsx +0 -135
  156. package/components/MFA/mfaMethods/index.tsx +0 -81
  157. package/components/MFA/mfaMethods/style.less +0 -39
  158. package/components/MFA/props.ts +0 -51
  159. package/components/MFA/styles.less +0 -92
  160. package/components/NeedHelpView/core/describeQuestions.tsx +0 -227
  161. package/components/NeedHelpView/index.tsx +0 -99
  162. package/components/RecoveryCode/core/useCode.tsx +0 -71
  163. package/components/RecoveryCode/index.tsx +0 -27
  164. package/components/RecoveryCode/interface.ts +0 -31
  165. package/components/RecoveryCode/style.less +0 -13
  166. package/components/Register/codemap.ts +0 -16
  167. package/components/Register/components/Agreements/index.tsx +0 -81
  168. package/components/Register/components/Agreements/style.less +0 -44
  169. package/components/Register/core/WithEmail.tsx +0 -250
  170. package/components/Register/core/WithPhone.tsx +0 -190
  171. package/components/Register/index.tsx +0 -122
  172. package/components/Register/props.ts +0 -50
  173. package/components/SendCode/SendCodeBtn.tsx +0 -96
  174. package/components/SendCode/index.tsx +0 -98
  175. package/components/SendCode/style.less +0 -31
  176. package/components/ShieldSpin/index.tsx +0 -27
  177. package/components/ShieldSpin/loading.svg +0 -29
  178. package/components/SubmitButton/index.tsx +0 -50
  179. package/components/Type/index.ts +0 -61
  180. package/components/VerifyCodeInput/index.tsx +0 -76
  181. package/components/VerifyCodeInput/style.less +0 -24
  182. package/components/_utils/GuardErrorCode.ts +0 -8
  183. package/components/_utils/clipboard.ts +0 -27
  184. package/components/_utils/config.ts +0 -123
  185. package/components/_utils/guradHttp.ts +0 -93
  186. package/components/_utils/hooks/index.ts +0 -56
  187. package/components/_utils/http.ts +0 -85
  188. package/components/_utils/index.ts +0 -310
  189. package/components/_utils/locales/en/common.json +0 -218
  190. package/components/_utils/locales/en/index.ts +0 -6
  191. package/components/_utils/locales/en/login.json +0 -95
  192. package/components/_utils/locales/en/map.json +0 -4
  193. package/components/_utils/locales/en/user.json +0 -82
  194. package/components/_utils/locales/index.ts +0 -45
  195. package/components/_utils/locales/zh/common.json +0 -218
  196. package/components/_utils/locales/zh/index.ts +0 -6
  197. package/components/_utils/locales/zh/login.json +0 -95
  198. package/components/_utils/locales/zh/map.json +0 -4
  199. package/components/_utils/locales/zh/user.json +0 -82
  200. package/components/_utils/popupCenter.ts +0 -48
  201. package/components/context/base.tsx +0 -28
  202. package/components/context/global/context.tsx +0 -39
  203. package/components/context/global/reducer.tsx +0 -56
  204. package/components/context/module/context.tsx +0 -23
  205. package/components/index.ts +0 -10
  206. package/config/antdReplacer.js +0 -51
  207. package/config/env.js +0 -104
  208. package/config/getHttpsConfig.js +0 -66
  209. package/config/jest/cssTransform.js +0 -14
  210. package/config/jest/fileTransform.js +0 -40
  211. package/config/modules.js +0 -134
  212. package/config/paths.js +0 -71
  213. package/config/pnpTs.js +0 -35
  214. package/config/webpack.config.js +0 -835
  215. package/config/webpackDevServer.config.js +0 -130
  216. package/examples.tsx +0 -100
  217. package/index.js +0 -1
  218. package/logo.svg +0 -7
  219. package/public/favicon.ico +0 -0
  220. package/public/index.html +0 -43
  221. package/public/logo192.png +0 -0
  222. package/public/logo512.png +0 -0
  223. package/public/manifest.json +0 -25
  224. package/public/robots.txt +0 -3
  225. package/react-app-env.d.ts +0 -71
  226. package/reportWebVitals.ts +0 -15
  227. package/scripts/build.js +0 -208
  228. package/scripts/lib.js +0 -200
  229. package/scripts/start.js +0 -162
  230. package/scripts/test.js +0 -49
  231. package/setupTests.ts +0 -5
  232. 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
- }