@authing/react-ui-components 3.0.2-beta.5 → 3.1.1-rc.1

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 (249) hide show
  1. package/.vscode/settings.json +1 -1
  2. package/LICENSE +21 -0
  3. package/config/env.js +26 -24
  4. package/config/paths.js +3 -3
  5. package/config/webpack.config.js +29 -7
  6. package/lib/index.d.ts +211 -1252
  7. package/lib/index.min.css +1 -2
  8. package/lib/index.min.js +1 -1
  9. package/lib/index.min.js.LICENSE.txt +0 -32
  10. package/package.json +14 -20
  11. package/scripts/build.js +83 -79
  12. package/scripts/start.js +73 -69
  13. package/scripts/test.js +23 -19
  14. package/{components → src/common}/AuthingDropdown/index.tsx +1 -1
  15. package/{components → src/common}/AuthingDropdown/style.less +0 -0
  16. package/{components → src/common}/AuthingTabs/index.tsx +1 -1
  17. package/{components → src/common}/AuthingTabs/style.less +0 -0
  18. package/{components → src/common}/CopyAbleText/index.tsx +1 -1
  19. package/{components → src/common}/CopyAbleText/style.less +0 -0
  20. package/{components → src/common}/VerifyCodeInput/index.tsx +0 -0
  21. package/{components → src/common}/VerifyCodeInput/style.less +0 -0
  22. package/{components → src/components}/AuthingGuard/AppMFALayout/index.tsx +2 -2
  23. package/{components → src/components}/AuthingGuard/AppMFALayout/style.less +0 -0
  24. package/{components → src/components}/AuthingGuard/CompleteUserInfoLayout/index.tsx +1 -1
  25. package/{components → src/components}/AuthingGuard/CompleteUserInfoLayout/style.less +0 -0
  26. package/{components → src/components}/AuthingGuard/Forms/ADLoginForm/index.tsx +2 -2
  27. package/{components → src/components}/AuthingGuard/Forms/Agreements/index.tsx +1 -1
  28. package/{components → src/components}/AuthingGuard/Forms/Agreements/style.less +0 -0
  29. package/{components → src/components}/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +3 -3
  30. package/{components → src/components}/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +4 -2
  31. package/{components → src/components}/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +2 -2
  32. package/{components → src/components}/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +1 -1
  33. package/{components → src/components}/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  34. package/{components → src/components}/AuthingGuard/Forms/EmailRegisterForm/index.tsx +2 -2
  35. package/{components → src/components}/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  36. package/{components → src/components}/AuthingGuard/Forms/LdapLoginForm/index.tsx +4 -9
  37. package/{components → src/components}/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  38. package/{components → src/components}/AuthingGuard/Forms/LoginFormFooter/index.tsx +1 -1
  39. package/{components → src/components}/AuthingGuard/Forms/LoginFormFooter/style.less +0 -0
  40. package/{components → src/components}/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +2 -2
  41. package/{components → src/components}/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +1 -1
  42. package/{components → src/components}/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +1 -1
  43. package/{components → src/components}/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -0
  44. package/{components → src/components}/AuthingGuard/Forms/MfaVerifyForm/index.tsx +2 -2
  45. package/{components → src/components}/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -0
  46. package/{components → src/components}/AuthingGuard/Forms/PasswordLoginForm/index.tsx +3 -3
  47. package/{components → src/components}/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +2 -2
  48. package/{components → src/components}/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +2 -2
  49. package/{components → src/components}/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +4 -2
  50. package/{components → src/components}/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -0
  51. package/{components → src/components}/AuthingGuard/Forms/RegisterFormFooter/index.tsx +1 -1
  52. package/{components → src/components}/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  53. package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +1 -1
  54. package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +2 -2
  55. package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +2 -2
  56. package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +2 -2
  57. package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +1 -1
  58. package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/index.tsx +1 -1
  59. package/{components → src/components}/AuthingGuard/Forms/ResetPwdForm/style.less +0 -0
  60. package/{components → src/components}/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -0
  61. package/{components → src/components}/AuthingGuard/Forms/SendPhoneCode/index.tsx +2 -2
  62. package/{components → src/components}/AuthingGuard/Forms/SendPhoneCode/style.less +0 -0
  63. package/{components → src/components}/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +2 -2
  64. package/{components → src/components}/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +2 -2
  65. package/{components → src/components}/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +1 -1
  66. package/{components → src/components}/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -0
  67. package/{components → src/components}/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +7 -7
  68. package/{components → src/components}/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -0
  69. package/{components → src/components}/AuthingGuard/Forms/UploadImage/index.tsx +1 -1
  70. package/{components → src/components}/AuthingGuard/Forms/index.ts +0 -0
  71. package/{components → src/components}/AuthingGuard/GuardLayout/index.tsx +17 -3
  72. package/{components → src/components}/AuthingGuard/GuardLayout/style.less +0 -0
  73. package/{components → src/components}/AuthingGuard/Header/index.tsx +6 -3
  74. package/{components → src/components}/AuthingGuard/Header/style.less +23 -11
  75. package/{components → src/components}/AuthingGuard/IconFont/iconfont.js +0 -0
  76. package/{components → src/components}/AuthingGuard/IconFont/index.tsx +1 -1
  77. package/{components → src/components}/AuthingGuard/IconFont/style.less +0 -0
  78. package/{components → src/components}/AuthingGuard/IconFont/svg.js +0 -0
  79. package/{components → src/components}/AuthingGuard/LoginLayout/index.tsx +69 -25
  80. package/{components → src/components}/AuthingGuard/LoginLayout/style.less +0 -0
  81. package/{components → src/components}/AuthingGuard/MfaLayout/Steps.ts +0 -0
  82. package/{components → src/components}/AuthingGuard/MfaLayout/index.tsx +1 -1
  83. package/{components → src/components}/AuthingGuard/MfaLayout/style.less +0 -0
  84. package/{components → src/components}/AuthingGuard/RegisterLayout/index.tsx +2 -2
  85. package/{components → src/components}/AuthingGuard/RegisterLayout/style.less +0 -0
  86. package/{components → src/components}/AuthingGuard/ResetPwdLayout/index.tsx +1 -1
  87. package/{components → src/components}/AuthingGuard/ToggleLang/index.tsx +2 -2
  88. package/{components → src/components}/AuthingGuard/api/appConfig.ts +22 -14
  89. package/{components/_utils → src/components/AuthingGuard/api}/http.ts +33 -30
  90. package/{components → src/components}/AuthingGuard/api/index.ts +0 -0
  91. package/{components → src/components}/AuthingGuard/api/sso.ts +1 -1
  92. package/{components → src/components}/AuthingGuard/api/userPoolConfig.ts +3 -2
  93. package/{components → src/components}/AuthingGuard/constants.ts +2 -2
  94. package/{components → src/components}/AuthingGuard/hooks/index.tsx +0 -0
  95. package/{components → src/components}/AuthingGuard/hooks/useScreenSize.tsx +0 -0
  96. package/{components → src/components}/AuthingGuard/index.tsx +11 -3
  97. package/{components/_utils → src/components/AuthingGuard}/locales/en/common.json +26 -70
  98. package/{components/_utils → src/components/AuthingGuard}/locales/en/index.ts +0 -0
  99. package/{components/_utils → src/components/AuthingGuard}/locales/en/login.json +19 -21
  100. package/{components/_utils → src/components/AuthingGuard}/locales/en/map.json +0 -0
  101. package/{components/_utils → src/components/AuthingGuard}/locales/en/user.json +3 -4
  102. package/{components/_utils → src/components/AuthingGuard}/locales/index.ts +2 -2
  103. package/{components/_utils → src/components/AuthingGuard}/locales/zh/common.json +9 -53
  104. package/{components/_utils → src/components/AuthingGuard}/locales/zh/index.ts +0 -0
  105. package/{components/_utils → src/components/AuthingGuard}/locales/zh/login.json +4 -6
  106. package/{components/_utils → src/components/AuthingGuard}/locales/zh/map.json +0 -0
  107. package/{components/_utils → src/components/AuthingGuard}/locales/zh/user.json +1 -3
  108. package/{components → src/components}/AuthingGuard/style.less +5 -0
  109. package/{components → src/components}/AuthingGuard/types/Forms.ts +2 -1
  110. package/{components → src/components}/AuthingGuard/types/GuardConfig.ts +5 -1
  111. package/{components → src/components}/AuthingGuard/types/GuardState.ts +1 -1
  112. package/{components → src/components}/AuthingGuard/types/Locales.ts +0 -0
  113. package/{components → src/components}/AuthingGuard/types/index.ts +0 -0
  114. package/src/components/index.ts +7 -0
  115. package/{components → src}/context/base.tsx +0 -0
  116. package/{components → src}/context/global/context.tsx +0 -0
  117. package/{components → src}/context/global/reducer.tsx +2 -2
  118. package/src/index.tsx +142 -0
  119. package/{logo.svg → src/logo.svg} +0 -0
  120. package/{react-app-env.d.ts → src/react-app-env.d.ts} +0 -0
  121. package/{reportWebVitals.ts → src/reportWebVitals.ts} +0 -0
  122. package/{setupTests.ts → src/setupTests.ts} +0 -0
  123. package/{components/_utils → src/utils}/clipboard.ts +1 -1
  124. package/{components/_utils → src/utils}/index.ts +3 -149
  125. package/{components/_utils → src/utils}/popupCenter.ts +0 -0
  126. package/tsconfig.json +2 -8
  127. package/build/asset-manifest.json +0 -26
  128. package/build/favicon.ico +0 -0
  129. package/build/index.html +0 -1
  130. package/build/logo192.png +0 -0
  131. package/build/logo512.png +0 -0
  132. package/build/manifest.json +0 -25
  133. package/build/robots.txt +0 -3
  134. package/build/static/css/2.51c07e65.chunk.css +0 -3
  135. package/build/static/css/2.51c07e65.chunk.css.map +0 -1
  136. package/build/static/css/main.779f221a.chunk.css +0 -2
  137. package/build/static/css/main.779f221a.chunk.css.map +0 -1
  138. package/build/static/js/2.bbae9fdb.chunk.js +0 -3
  139. package/build/static/js/2.bbae9fdb.chunk.js.LICENSE.txt +0 -102
  140. package/build/static/js/2.bbae9fdb.chunk.js.map +0 -1
  141. package/build/static/js/3.fd17f196.chunk.js +0 -2
  142. package/build/static/js/3.fd17f196.chunk.js.map +0 -1
  143. package/build/static/js/main.5f341531.chunk.js +0 -2
  144. package/build/static/js/main.5f341531.chunk.js.map +0 -1
  145. package/build/static/js/runtime-main.ef138021.js +0 -2
  146. package/build/static/js/runtime-main.ef138021.js.map +0 -1
  147. package/build/static/media/loading.4a67a5f3.svg +0 -29
  148. package/components/BindTotp/core/bindSuccess.tsx +0 -72
  149. package/components/BindTotp/core/securityCode.tsx +0 -108
  150. package/components/BindTotp/index.tsx +0 -134
  151. package/components/BindTotp/interface.ts +0 -30
  152. package/components/BindTotp/styles.less +0 -57
  153. package/components/ChangeLanguage/index.tsx +0 -35
  154. package/components/ChangePassword/core/firstLoginReset.tsx +0 -111
  155. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  156. package/components/ChangePassword/index.tsx +0 -72
  157. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  158. package/components/CompleteInfo/index.tsx +0 -45
  159. package/components/CompleteInfo/interface.ts +0 -40
  160. package/components/CompleteInfo/styles.less +0 -7
  161. package/components/DownloadAuthenticator/index.tsx +0 -97
  162. package/components/DownloadAuthenticator/interface.ts +0 -22
  163. package/components/DownloadAuthenticator/styles.less +0 -52
  164. package/components/Error/index.tsx +0 -21
  165. package/components/Error/interface.ts +0 -9
  166. package/components/Error/styles.less +0 -12
  167. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  168. package/components/ForgetPassword/index.tsx +0 -78
  169. package/components/ForgetPassword/interface.ts +0 -32
  170. package/components/Guard/Guard.tsx +0 -295
  171. package/components/Guard/authClient.ts +0 -44
  172. package/components/Guard/config.ts +0 -19
  173. package/components/Guard/event.ts +0 -52
  174. package/components/Guard/index.tsx +0 -4
  175. package/components/Guard/module.ts +0 -20
  176. package/components/Guard/stateMachine.ts +0 -152
  177. package/components/Guard/styles.less +0 -461
  178. package/components/IconFont/iconfont.js +0 -74
  179. package/components/IconFont/index.tsx +0 -16
  180. package/components/IconFont/style.less +0 -6
  181. package/components/IconFont/svg.js +0 -2
  182. package/components/ImagePro/index.tsx +0 -53
  183. package/components/ImagePro/styles.less +0 -40
  184. package/components/InputNumber/index.tsx +0 -33
  185. package/components/Login/codemap.ts +0 -49
  186. package/components/Login/core/withAD.tsx +0 -9
  187. package/components/Login/core/withAppQrcode.tsx +0 -49
  188. package/components/Login/core/withLDAP.tsx +0 -146
  189. package/components/Login/core/withPassword/FormItemAccount.tsx +0 -42
  190. package/components/Login/core/withPassword/GraphicVerifyCode.tsx +0 -30
  191. package/components/Login/core/withPassword/InputAccount.tsx +0 -64
  192. package/components/Login/core/withPassword/index.tsx +0 -173
  193. package/components/Login/core/withPhonecode.tsx +0 -122
  194. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  195. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  196. package/components/Login/index.tsx +0 -374
  197. package/components/Login/props.ts +0 -74
  198. package/components/Login/socialLogin/index.tsx +0 -407
  199. package/components/Login/socialLogin/style.less +0 -69
  200. package/components/Login/styles.less +0 -53
  201. package/components/MFA/VerifyCodeInput/VerifyCodeFormItem.tsx +0 -41
  202. package/components/MFA/VerifyCodeInput/index.tsx +0 -145
  203. package/components/MFA/VerifyCodeInput/style.less +0 -35
  204. package/components/MFA/codemap.ts +0 -24
  205. package/components/MFA/core/email.tsx +0 -203
  206. package/components/MFA/core/face.tsx +0 -297
  207. package/components/MFA/core/face_deps.tsx +0 -37
  208. package/components/MFA/core/sms.tsx +0 -203
  209. package/components/MFA/core/totp.tsx +0 -122
  210. package/components/MFA/index.tsx +0 -143
  211. package/components/MFA/mfaMethods/index.tsx +0 -88
  212. package/components/MFA/mfaMethods/style.less +0 -39
  213. package/components/MFA/props.ts +0 -51
  214. package/components/MFA/styles.less +0 -100
  215. package/components/NeedHelpView/core/describeQuestions.tsx +0 -245
  216. package/components/NeedHelpView/index.tsx +0 -47
  217. package/components/RecoveryCode/core/useCode.tsx +0 -71
  218. package/components/RecoveryCode/index.tsx +0 -27
  219. package/components/RecoveryCode/interface.ts +0 -31
  220. package/components/RecoveryCode/style.less +0 -13
  221. package/components/Register/codemap.ts +0 -12
  222. package/components/Register/components/Agreements/index.tsx +0 -81
  223. package/components/Register/components/Agreements/style.less +0 -44
  224. package/components/Register/core/WithEmail.tsx +0 -242
  225. package/components/Register/core/WithPhone.tsx +0 -184
  226. package/components/Register/index.tsx +0 -139
  227. package/components/Register/props.ts +0 -50
  228. package/components/SendCode/SendCodeBtn.tsx +0 -96
  229. package/components/SendCode/index.tsx +0 -94
  230. package/components/SendCode/style.less +0 -31
  231. package/components/ShieldSpin/index.tsx +0 -27
  232. package/components/ShieldSpin/loading.svg +0 -29
  233. package/components/SubmitButton/index.tsx +0 -50
  234. package/components/SubmitSuccess/index.tsx +0 -66
  235. package/components/SubmitSuccess/interface.ts +0 -17
  236. package/components/Type/index.ts +0 -52
  237. package/components/ValidatorRules/ValidatorFormItem.tsx +0 -139
  238. package/components/ValidatorRules/index.ts +0 -20
  239. package/components/_utils/GuardErrorCode.ts +0 -9
  240. package/components/_utils/config.ts +0 -116
  241. package/components/_utils/guradHttp.ts +0 -101
  242. package/components/_utils/hooks/index.ts +0 -64
  243. package/components/assets/images/error.png +0 -0
  244. package/components/context/module/context.tsx +0 -23
  245. package/components/index.ts +0 -12
  246. package/examples.tsx +0 -87
  247. package/index.js +0 -1
  248. package/lib/static/media/loading.4a67a5f3.svg +0 -29
  249. package/scripts/publish.js +0 -57
@@ -1,30 +0,0 @@
1
- import Input, { InputProps } from 'antd/lib/input'
2
- import React from 'react'
3
- import { useTranslation } from 'react-i18next'
4
- import { ImagePro } from '../../../ImagePro'
5
-
6
- export interface GraphicVerifyCodeProps extends InputProps {
7
- verifyCodeUrl: string
8
- changeCode: () => void
9
- }
10
-
11
- export const GraphicVerifyCode: React.FC<GraphicVerifyCodeProps> = (props) => {
12
- const { verifyCodeUrl, changeCode, ...inputProps } = props
13
-
14
- const { t } = useTranslation()
15
-
16
- return (
17
- <div className="g2-graphic-verify-code">
18
- <Input {...inputProps} />
19
-
20
- <ImagePro
21
- className="g2-captcha-code-image"
22
- src={verifyCodeUrl}
23
- alt={t('login.captchaCode')}
24
- height="46px"
25
- style={{ cursor: 'pointer' }}
26
- onClick={() => changeCode()}
27
- />
28
- </div>
29
- )
30
- }
@@ -1,64 +0,0 @@
1
- import Input, { InputProps } from 'antd/lib/input'
2
- import React, { useMemo } from 'react'
3
- import { useTranslation } from 'react-i18next'
4
- import { PasswordLoginMethods } from '../../../AuthingGuard/api'
5
- import { InputNumber } from '../../../InputNumber'
6
-
7
- export interface InputAccountProps extends InputProps {
8
- passwordLoginMethods: PasswordLoginMethods[]
9
- }
10
-
11
- export const InputAccount: React.FC<InputAccountProps> = (props) => {
12
- const { passwordLoginMethods: methods, ...inputProps } = props
13
-
14
- const { t } = useTranslation()
15
-
16
- const loginMethodsText = useMemo<
17
- Record<
18
- PasswordLoginMethods,
19
- {
20
- t: string
21
- sort: number
22
- }
23
- >
24
- >(
25
- () => ({
26
- 'email-password': {
27
- t: t('common.email'),
28
- sort: 2,
29
- },
30
- 'phone-password': {
31
- t: t('common.phoneNumber'),
32
- sort: 1,
33
- },
34
- 'username-password': {
35
- t: t('common.username'),
36
- sort: 0,
37
- },
38
- }),
39
- [t]
40
- )
41
-
42
- const placeholder = useMemo(
43
- () =>
44
- t('login.inputAccount', {
45
- text: methods
46
- ?.map((item) => loginMethodsText[item])
47
- .sort((a, b) => a.sort - b.sort)
48
- .map((item) => item.t)
49
- .join(' / '),
50
- }),
51
- [loginMethodsText, methods, t]
52
- )
53
-
54
- const runderInput = useMemo(() => {
55
- if (methods.length === 1 && methods[0] === 'phone-password')
56
- return (
57
- <InputNumber maxLength={11} placeholder={placeholder} {...inputProps} />
58
- )
59
-
60
- return <Input placeholder={placeholder} {...inputProps} />
61
- }, [inputProps, methods, placeholder])
62
-
63
- return <>{runderInput}</>
64
- }
@@ -1,173 +0,0 @@
1
- import React, { useRef, useState } from 'react'
2
- import { Form, Input } from 'antd'
3
- import { UserOutlined, LockOutlined } from '@ant-design/icons'
4
- import { useTranslation } from 'react-i18next'
5
-
6
- import { useGuardHttp } from '../../../_utils/guradHttp'
7
- import { useAuthClient } from '../../../Guard/authClient'
8
- import { fieldRequiredRule, getUserRegisterParams } from '../../../_utils'
9
- import { ErrorCode } from '../../../_utils/GuardErrorCode'
10
- import SubmitButton from '../../../SubmitButton'
11
- import { PasswordLoginMethods } from '../../../AuthingGuard/api'
12
- import { LoginMethods } from '../../..'
13
- import { FormItemAccount } from './FormItemAccount'
14
- import { InputAccount } from './InputAccount'
15
- import { GraphicVerifyCode } from './GraphicVerifyCode'
16
-
17
- interface LoginWithPasswordProps {
18
- // configs
19
- publicKey: string
20
- autoRegister?: boolean
21
- host?: string
22
-
23
- // events
24
- onLogin: any
25
- onBeforeLogin: any
26
- passwordLoginMethods: PasswordLoginMethods[]
27
- }
28
-
29
- export const LoginWithPassword = (props: LoginWithPasswordProps) => {
30
- let { t } = useTranslation()
31
- let { post } = useGuardHttp()
32
- let client = useAuthClient()
33
-
34
- let submitButtonRef = useRef<any>(null)
35
-
36
- const [showCaptcha, setShowCaptcha] = useState(false)
37
- const [verifyCodeUrl, setVerifyCodeUrl] = useState('')
38
- const [remainCount, setRemainCount] = useState(0)
39
-
40
- const captchaUrl = `${props.host}/api/v2/security/captcha`
41
- const getCaptchaUrl = () => `${captchaUrl}?r=${+new Date()}`
42
-
43
- const encrypt = client.options.encryptFunction
44
-
45
- const onFinish = async (values: any) => {
46
- setRemainCount(0)
47
- // onBeforeLogin
48
- submitButtonRef?.current.onSpin(true)
49
- let loginInfo = {
50
- type: LoginMethods.Password,
51
- data: {
52
- identity: values.account,
53
- password: values.password,
54
- captchaCode: values.captchaCode,
55
- },
56
- }
57
- let context = await props.onBeforeLogin(loginInfo)
58
- if (!context) {
59
- submitButtonRef?.current.onSpin(false)
60
- return
61
- }
62
-
63
- // onLogin
64
- let url = '/api/v2/login/account'
65
- let account = values.account && values.account.trim()
66
- let password = values.password && values.password.trim()
67
- let captchaCode = values.captchaCode && values.captchaCode.trim()
68
-
69
- let body = {
70
- account: account,
71
- password: await encrypt!(password, props.publicKey),
72
- captchaCode,
73
- customData: getUserRegisterParams(),
74
- autoRegister: props.autoRegister,
75
- }
76
- const { code, message, data } = await post(url, body)
77
-
78
- if (code !== 200) {
79
- submitButtonRef.current.onError()
80
- }
81
-
82
- if (code === ErrorCode.INPUT_CAPTCHACODE) {
83
- setVerifyCodeUrl(getCaptchaUrl())
84
- setShowCaptcha(true)
85
- }
86
- if (code === ErrorCode.PASSWORD_ERROR) {
87
- if ((data as any)?.remainCount) {
88
- setRemainCount((data as any)?.remainCount ?? 0)
89
- }
90
- }
91
- submitButtonRef?.current.onSpin(false)
92
- props.onLogin(code, data, message)
93
- }
94
-
95
- return (
96
- <div className="authing-g2-login-password">
97
- <Form
98
- name="passworLogin"
99
- onFinish={onFinish}
100
- onFinishFailed={() => submitButtonRef.current.onError()}
101
- autoComplete="off"
102
- >
103
- <FormItemAccount
104
- name="account"
105
- className="authing-g2-input-form"
106
- passwordLoginMethods={props.passwordLoginMethods}
107
- >
108
- <InputAccount
109
- className="authing-g2-input"
110
- autoComplete="email,username,tel"
111
- size="large"
112
- prefix={<UserOutlined style={{ color: '#878A95' }} />}
113
- passwordLoginMethods={props.passwordLoginMethods}
114
- />
115
- </FormItemAccount>
116
- <Form.Item
117
- name="password"
118
- className="authing-g2-input-form"
119
- rules={fieldRequiredRule(t('common.password'))}
120
- >
121
- <Input.Password
122
- className="authing-g2-input"
123
- size="large"
124
- placeholder={t('login.inputLoginPwd')}
125
- prefix={<LockOutlined style={{ color: '#878A95' }} />}
126
- />
127
- </Form.Item>
128
- {/* 图形验证码 */}
129
- {showCaptcha && (
130
- <Form.Item
131
- className="authing-g2-input-form"
132
- name="captchaCode"
133
- rules={fieldRequiredRule(t('common.captchaCode'))}
134
- >
135
- <GraphicVerifyCode
136
- className="authing-g2-input"
137
- size="large"
138
- placeholder={t('login.inputCaptchaCode')}
139
- verifyCodeUrl={verifyCodeUrl}
140
- changeCode={() => setVerifyCodeUrl(getCaptchaUrl())}
141
- />
142
- </Form.Item>
143
- )}
144
- {remainCount !== 0 && (
145
- <span
146
- style={{
147
- marginBottom: 23,
148
- fontSize: 12,
149
- color: '#E63333',
150
- display: 'block',
151
- }}
152
- >
153
- {t('common.loginFailCheck', {
154
- number: remainCount,
155
- })}
156
- </span>
157
- )}
158
-
159
- <Form.Item>
160
- <SubmitButton
161
- text={
162
- props.autoRegister
163
- ? `${t('common.login')} / ${t('common.register')}`
164
- : t('common.login')
165
- }
166
- className="password"
167
- ref={submitButtonRef}
168
- />
169
- </Form.Item>
170
- </Form>
171
- </div>
172
- )
173
- }
@@ -1,122 +0,0 @@
1
- import React, { useRef } from 'react'
2
- import { Form } from 'antd'
3
- import { useTranslation } from 'react-i18next'
4
- import { useAuthClient } from '../../Guard/authClient'
5
- import { UserOutlined, SafetyOutlined } from '@ant-design/icons'
6
- import { LoginMethods } from '../../'
7
- import { SendCode } from '../../SendCode'
8
- import { fieldRequiredRule } from '../../_utils'
9
- import SubmitButton from '../../SubmitButton'
10
- import { InputNumber } from '../../InputNumber'
11
- import { PhoneFormItem } from '../../ValidatorRules'
12
-
13
- // const formatPhone = (value: any) => {
14
- // if (!value) {
15
- // return ''
16
- // }
17
- // let a = value.slice(0, 3)
18
- // let b = value.slice(3, 7)
19
- // let c = value.slice(7, 11)
20
- // if (value.length < 4) {
21
- // return a
22
- // } else if (value.length < 8) {
23
- // return `${a}-${b}`
24
- // } else {
25
- // return `${a}-${b}-${c}`
26
- // }
27
- // }
28
- export const LoginWithPhoneCode = (props: any) => {
29
- let [form] = Form.useForm()
30
- let submitButtonRef = useRef<any>(null)
31
- const { t } = useTranslation()
32
-
33
- let client = useAuthClient()
34
-
35
- const verifyCodeLength = props.verifyCodeLength ?? 4
36
-
37
- const onFinish = async (values: any) => {
38
- submitButtonRef.current.onSpin(true)
39
- // onBeforeLogin
40
- let loginInfo = {
41
- type: LoginMethods.Password,
42
- data: {
43
- phone: values.phone,
44
- code: values.code,
45
- },
46
- }
47
- let context = await props.onBeforeLogin(loginInfo)
48
- if (!context) {
49
- submitButtonRef.current.onSpin(false)
50
- return
51
- }
52
-
53
- let loginContext = client.loginByPhoneCode(values.phone, values.code)
54
- loginContext
55
- .then((u) => {
56
- submitButtonRef.current.onSpin(false)
57
- props.onLogin(200, u)
58
- })
59
- .catch((e) => {
60
- submitButtonRef.current.onSpin(false)
61
- props.onLogin(e.code, e.data, e.message)
62
- })
63
- }
64
-
65
- return (
66
- <div className="authing-g2-login-phone-code">
67
- <Form
68
- name="phoneCode"
69
- form={form}
70
- onFinish={onFinish}
71
- onFinishFailed={() => submitButtonRef.current.onError()}
72
- autoComplete="off"
73
- >
74
- <PhoneFormItem className="authing-g2-input-form" name="phone">
75
- <InputNumber
76
- className="authing-g2-input"
77
- autoComplete="tel"
78
- type="tel"
79
- size="large"
80
- // 只有 InputNumber formatter、controls API
81
- maxLength={11}
82
- // formatter={formatPhone}
83
- // parser={(value) => (value ? value.replaceAll('-', '') : '')}
84
- placeholder={t('login.inputPhone')}
85
- prefix={<UserOutlined style={{ color: '#878A95' }} />}
86
- />
87
- </PhoneFormItem>
88
- <Form.Item
89
- className="authing-g2-input-form"
90
- name="code"
91
- rules={fieldRequiredRule(t('common.captchaCode'))}
92
- >
93
- <SendCode
94
- className="authing-g2-input"
95
- autoComplete="one-time-code"
96
- size="large"
97
- placeholder={t('common.inputFourVerifyCode', {
98
- length: verifyCodeLength,
99
- })}
100
- maxLength={verifyCodeLength}
101
- prefix={<SafetyOutlined style={{ color: '#878A95' }} />}
102
- method="phone"
103
- data={''}
104
- form={form}
105
- onSendCodeBefore={() => form.validateFields(['phone'])}
106
- />
107
- </Form.Item>
108
- <Form.Item>
109
- <SubmitButton
110
- text={
111
- props.autoRegister
112
- ? `${t('common.login')} / ${t('common.register')}`
113
- : t('common.login')
114
- }
115
- className="password"
116
- ref={submitButtonRef}
117
- />
118
- </Form.Item>
119
- </Form>
120
- </div>
121
- )
122
- }
@@ -1,60 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react'
2
- import { message } from 'antd'
3
- import { ShieldSpin } from '../../ShieldSpin'
4
- import { useAuthClient } from '../../Guard/authClient'
5
-
6
- interface LoginWithWechatMiniQrcodeProps {
7
- onLogin: any
8
- canLoop: boolean
9
- qrCodeScanOptions: any
10
- }
11
-
12
- export const LoginWithWechatMiniQrcode = (
13
- props: LoginWithWechatMiniQrcodeProps
14
- ) => {
15
- const timerRef = useRef<any>()
16
- const client = useAuthClient()
17
- const [loading, setLoading] = useState(true)
18
- const appQrcodeClient = client.wxqrcode
19
-
20
- useEffect(() => {
21
- return () => {
22
- clearInterval(timerRef.current)
23
- }
24
- }, [])
25
-
26
- useEffect(() => {
27
- if (!props.canLoop) {
28
- return
29
- }
30
- appQrcodeClient.startScanning('authingGuardMiniQrcode', {
31
- autoExchangeUserInfo: true,
32
- ...props.qrCodeScanOptions,
33
- onCodeLoaded() {
34
- setLoading(false)
35
- },
36
- onStart(timer) {
37
- // console.log('开始扫码')
38
- timerRef.current = timer
39
- },
40
- onSuccess(user) {
41
- // console.log('扫码完成', user)
42
- // onSuccess && onSuccess(user as User)
43
- props.onLogin(200, user)
44
- },
45
- onError: (ms) => {
46
- // config.qrCodeScanOptions?.onError?.(message)
47
- // onFail && onFail(`${message}`)
48
- message.error(ms)
49
- },
50
- })
51
- // eslint-disable-next-line react-hooks/exhaustive-deps
52
- }, [appQrcodeClient, props.canLoop, props.qrCodeScanOptions])
53
-
54
- return (
55
- <div className="authing-g2-login-app-qrcode">
56
- {loading && <ShieldSpin />}
57
- <div id="authingGuardMiniQrcode"></div>
58
- </div>
59
- )
60
- }
@@ -1,53 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react'
2
- import { ShieldSpin } from '../../ShieldSpin'
3
- import { useAuthClient } from '../../Guard/authClient'
4
-
5
- interface LoginWithWechatmpQrcodeProps {
6
- onLogin: any
7
- canLoop: boolean
8
- qrCodeScanOptions: any
9
- }
10
-
11
- export const LoginWithWechatmpQrcode = (
12
- props: LoginWithWechatmpQrcodeProps
13
- ) => {
14
- const timerRef = useRef<any>()
15
- const client = useAuthClient()
16
- const [loading, setLoading] = useState(true)
17
-
18
- const appQrcodeClient = client.wechatmpqrcode
19
- // const config = props.config
20
-
21
- useEffect(() => {
22
- if (!props.canLoop) {
23
- return
24
- }
25
- appQrcodeClient.startScanning('authingGuardMpQrcode', {
26
- autoExchangeUserInfo: true,
27
- ...props.qrCodeScanOptions,
28
- onCodeLoaded() {
29
- setLoading(false)
30
- },
31
- onStart(timer) {
32
- timerRef.current = timer
33
- },
34
- onSuccess(user) {
35
- props.onLogin(200, user)
36
- // onSuccess && onSuccess(user as User)
37
- },
38
- onError: (message) => {
39
- // config.qrCodeScanOptions?.onError?.(message)
40
- // onFail && onFail(`${message}`)
41
- },
42
- })
43
- return () => clearInterval(timerRef.current)
44
- // eslint-disable-next-line react-hooks/exhaustive-deps
45
- }, [appQrcodeClient, props.canLoop, props.qrCodeScanOptions])
46
-
47
- return (
48
- <div className="authing-g2-login-app-qrcode">
49
- {loading && <ShieldSpin />}
50
- <div id="authingGuardMpQrcode"></div>
51
- </div>
52
- )
53
- }