@authing/react-ui-components 3.0.2-beta.7 → 3.0.3-rc.4

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 (260) hide show
  1. package/lib/index.d.ts +4263 -0
  2. package/lib/index.min.css +2 -0
  3. package/lib/index.min.js +2 -0
  4. package/{build/static/js/2.142555a1.chunk.js.LICENSE.txt → lib/index.min.js.LICENSE.txt} +8 -31
  5. package/{build → lib}/static/media/loading.4a67a5f3.svg +0 -0
  6. package/package.json +35 -12
  7. package/.eslintignore +0 -6
  8. package/.eslintrc.js +0 -7
  9. package/.prettierrc +0 -5
  10. package/build/asset-manifest.json +0 -26
  11. package/build/favicon.ico +0 -0
  12. package/build/index.html +0 -1
  13. package/build/logo192.png +0 -0
  14. package/build/logo512.png +0 -0
  15. package/build/manifest.json +0 -25
  16. package/build/robots.txt +0 -3
  17. package/build/static/css/2.5c23c9b8.chunk.css +0 -3
  18. package/build/static/css/2.5c23c9b8.chunk.css.map +0 -1
  19. package/build/static/css/main.6a8701e8.chunk.css +0 -2
  20. package/build/static/css/main.6a8701e8.chunk.css.map +0 -1
  21. package/build/static/js/2.142555a1.chunk.js +0 -3
  22. package/build/static/js/2.142555a1.chunk.js.map +0 -1
  23. package/build/static/js/3.ed27e06b.chunk.js +0 -2
  24. package/build/static/js/3.ed27e06b.chunk.js.map +0 -1
  25. package/build/static/js/main.8d075e4d.chunk.js +0 -2
  26. package/build/static/js/main.8d075e4d.chunk.js.map +0 -1
  27. package/build/static/js/runtime-main.9a428724.js +0 -2
  28. package/build/static/js/runtime-main.9a428724.js.map +0 -1
  29. package/components/AuthingDropdown/index.tsx +0 -52
  30. package/components/AuthingDropdown/style.less +0 -43
  31. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  32. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  33. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  34. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  35. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  36. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  37. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  38. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  39. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  40. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  41. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  42. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  43. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  44. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  45. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  46. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  47. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  48. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  49. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  50. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  51. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  52. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  53. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  54. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  55. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  56. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  57. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  58. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  59. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  60. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  61. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  62. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  63. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  64. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  65. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  66. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  67. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  68. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  69. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  70. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  71. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  72. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  73. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  74. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  75. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  76. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  77. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  78. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  79. package/components/AuthingGuard/Forms/index.ts +0 -13
  80. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  81. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  82. package/components/AuthingGuard/Header/index.tsx +0 -25
  83. package/components/AuthingGuard/Header/style.less +0 -52
  84. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  85. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  86. package/components/AuthingGuard/IconFont/style.less +0 -6
  87. package/components/AuthingGuard/IconFont/svg.js +0 -2
  88. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  89. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  90. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  91. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  92. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  93. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  94. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  95. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  96. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  97. package/components/AuthingGuard/api/appConfig.ts +0 -146
  98. package/components/AuthingGuard/api/index.ts +0 -3
  99. package/components/AuthingGuard/api/sso.ts +0 -29
  100. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  101. package/components/AuthingGuard/constants.ts +0 -107
  102. package/components/AuthingGuard/hooks/index.tsx +0 -70
  103. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  104. package/components/AuthingGuard/index.tsx +0 -126
  105. package/components/AuthingGuard/style.less +0 -103
  106. package/components/AuthingGuard/types/Forms.ts +0 -94
  107. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  108. package/components/AuthingGuard/types/GuardState.ts +0 -7
  109. package/components/AuthingGuard/types/Locales.ts +0 -12
  110. package/components/AuthingGuard/types/index.ts +0 -4
  111. package/components/AuthingTabs/index.tsx +0 -98
  112. package/components/AuthingTabs/style.less +0 -135
  113. package/components/BindTotp/core/bindSuccess.tsx +0 -72
  114. package/components/BindTotp/core/securityCode.tsx +0 -108
  115. package/components/BindTotp/index.tsx +0 -134
  116. package/components/BindTotp/interface.ts +0 -30
  117. package/components/BindTotp/styles.less +0 -57
  118. package/components/ChangeLanguage/index.tsx +0 -35
  119. package/components/ChangePassword/core/firstLoginReset.tsx +0 -111
  120. package/components/ChangePassword/core/rotateReset.tsx +0 -125
  121. package/components/ChangePassword/index.tsx +0 -72
  122. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  123. package/components/CompleteInfo/index.tsx +0 -45
  124. package/components/CompleteInfo/interface.ts +0 -40
  125. package/components/CompleteInfo/styles.less +0 -7
  126. package/components/CopyAbleText/index.tsx +0 -54
  127. package/components/CopyAbleText/style.less +0 -13
  128. package/components/DownloadAuthenticator/index.tsx +0 -97
  129. package/components/DownloadAuthenticator/interface.ts +0 -22
  130. package/components/DownloadAuthenticator/styles.less +0 -52
  131. package/components/Error/index.tsx +0 -21
  132. package/components/Error/interface.ts +0 -9
  133. package/components/Error/styles.less +0 -12
  134. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  135. package/components/ForgetPassword/index.tsx +0 -78
  136. package/components/ForgetPassword/interface.ts +0 -32
  137. package/components/Guard/Guard.tsx +0 -295
  138. package/components/Guard/authClient.ts +0 -44
  139. package/components/Guard/config.ts +0 -19
  140. package/components/Guard/event.ts +0 -52
  141. package/components/Guard/index.tsx +0 -4
  142. package/components/Guard/module.ts +0 -20
  143. package/components/Guard/stateMachine.ts +0 -152
  144. package/components/Guard/styles.less +0 -461
  145. package/components/IconFont/iconfont.js +0 -74
  146. package/components/IconFont/index.tsx +0 -16
  147. package/components/IconFont/style.less +0 -6
  148. package/components/IconFont/svg.js +0 -2
  149. package/components/ImagePro/index.tsx +0 -53
  150. package/components/ImagePro/styles.less +0 -40
  151. package/components/InputNumber/index.tsx +0 -33
  152. package/components/Login/codemap.ts +0 -49
  153. package/components/Login/core/withAD.tsx +0 -9
  154. package/components/Login/core/withAppQrcode.tsx +0 -49
  155. package/components/Login/core/withLDAP.tsx +0 -146
  156. package/components/Login/core/withPassword/FormItemAccount.tsx +0 -42
  157. package/components/Login/core/withPassword/GraphicVerifyCode.tsx +0 -30
  158. package/components/Login/core/withPassword/InputAccount.tsx +0 -64
  159. package/components/Login/core/withPassword/index.tsx +0 -173
  160. package/components/Login/core/withPhonecode.tsx +0 -122
  161. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  162. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  163. package/components/Login/index.tsx +0 -374
  164. package/components/Login/interface.ts +0 -74
  165. package/components/Login/socialLogin/index.tsx +0 -407
  166. package/components/Login/socialLogin/style.less +0 -69
  167. package/components/Login/styles.less +0 -53
  168. package/components/MFA/VerifyCodeInput/VerifyCodeFormItem.tsx +0 -41
  169. package/components/MFA/VerifyCodeInput/index.tsx +0 -145
  170. package/components/MFA/VerifyCodeInput/style.less +0 -35
  171. package/components/MFA/codemap.ts +0 -24
  172. package/components/MFA/core/email.tsx +0 -203
  173. package/components/MFA/core/face.tsx +0 -297
  174. package/components/MFA/core/face_deps.tsx +0 -37
  175. package/components/MFA/core/sms.tsx +0 -203
  176. package/components/MFA/core/totp.tsx +0 -122
  177. package/components/MFA/index.tsx +0 -143
  178. package/components/MFA/interface.ts +0 -51
  179. package/components/MFA/mfaMethods/index.tsx +0 -88
  180. package/components/MFA/mfaMethods/style.less +0 -39
  181. package/components/MFA/styles.less +0 -100
  182. package/components/NeedHelpView/core/describeQuestions.tsx +0 -245
  183. package/components/NeedHelpView/index.tsx +0 -47
  184. package/components/RecoveryCode/core/useCode.tsx +0 -71
  185. package/components/RecoveryCode/index.tsx +0 -27
  186. package/components/RecoveryCode/interface.ts +0 -31
  187. package/components/RecoveryCode/style.less +0 -13
  188. package/components/Register/codemap.ts +0 -12
  189. package/components/Register/components/Agreements/index.tsx +0 -81
  190. package/components/Register/components/Agreements/style.less +0 -44
  191. package/components/Register/core/WithEmail.tsx +0 -242
  192. package/components/Register/core/WithPhone.tsx +0 -184
  193. package/components/Register/index.tsx +0 -139
  194. package/components/Register/interface.ts +0 -50
  195. package/components/SendCode/SendCodeBtn.tsx +0 -96
  196. package/components/SendCode/index.tsx +0 -94
  197. package/components/SendCode/style.less +0 -31
  198. package/components/ShieldSpin/index.tsx +0 -27
  199. package/components/ShieldSpin/loading.svg +0 -29
  200. package/components/SubmitButton/index.tsx +0 -50
  201. package/components/SubmitSuccess/index.tsx +0 -66
  202. package/components/SubmitSuccess/interface.ts +0 -17
  203. package/components/Type/index.ts +0 -52
  204. package/components/ValidatorRules/ValidatorFormItem.tsx +0 -139
  205. package/components/ValidatorRules/index.ts +0 -20
  206. package/components/VerifyCodeInput/index.tsx +0 -76
  207. package/components/VerifyCodeInput/style.less +0 -24
  208. package/components/_utils/GuardErrorCode.ts +0 -9
  209. package/components/_utils/clipboard.ts +0 -27
  210. package/components/_utils/config.ts +0 -116
  211. package/components/_utils/guradHttp.ts +0 -101
  212. package/components/_utils/hooks/index.ts +0 -64
  213. package/components/_utils/http.ts +0 -85
  214. package/components/_utils/index.ts +0 -326
  215. package/components/_utils/locales/en/common.json +0 -229
  216. package/components/_utils/locales/en/index.ts +0 -6
  217. package/components/_utils/locales/en/login.json +0 -96
  218. package/components/_utils/locales/en/map.json +0 -4
  219. package/components/_utils/locales/en/user.json +0 -82
  220. package/components/_utils/locales/index.ts +0 -45
  221. package/components/_utils/locales/zh/common.json +0 -229
  222. package/components/_utils/locales/zh/index.ts +0 -6
  223. package/components/_utils/locales/zh/login.json +0 -96
  224. package/components/_utils/locales/zh/map.json +0 -4
  225. package/components/_utils/locales/zh/user.json +0 -83
  226. package/components/_utils/popupCenter.ts +0 -48
  227. package/components/assets/images/error.png +0 -0
  228. package/components/context/base.tsx +0 -28
  229. package/components/context/global/context.tsx +0 -39
  230. package/components/context/global/reducer.tsx +0 -56
  231. package/components/context/module/context.tsx +0 -23
  232. package/components/index.ts +0 -9
  233. package/config/antdReplacer.js +0 -51
  234. package/config/env.js +0 -104
  235. package/config/getHttpsConfig.js +0 -66
  236. package/config/jest/cssTransform.js +0 -14
  237. package/config/jest/fileTransform.js +0 -40
  238. package/config/modules.js +0 -134
  239. package/config/paths.js +0 -71
  240. package/config/pnpTs.js +0 -35
  241. package/config/webpack.config.js +0 -835
  242. package/config/webpackDevServer.config.js +0 -130
  243. package/examples.tsx +0 -87
  244. package/index.js +0 -1
  245. package/logo.svg +0 -7
  246. package/public/favicon.ico +0 -0
  247. package/public/index.html +0 -43
  248. package/public/logo192.png +0 -0
  249. package/public/logo512.png +0 -0
  250. package/public/manifest.json +0 -25
  251. package/public/robots.txt +0 -3
  252. package/react-app-env.d.ts +0 -71
  253. package/reportWebVitals.ts +0 -15
  254. package/scripts/build.js +0 -208
  255. package/scripts/lib.js +0 -200
  256. package/scripts/publish.js +0 -57
  257. package/scripts/start.js +0 -162
  258. package/scripts/test.js +0 -49
  259. package/setupTests.ts +0 -5
  260. package/tsconfig.json +0 -30
@@ -1,474 +0,0 @@
1
- import { message, Spin } from 'antd'
2
- import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'
3
-
4
- import {
5
- getClassnames,
6
- insertStyles,
7
- deepMerge,
8
- removeStyles,
9
- } from '../../_utils'
10
- import { useGuardContext } from '../../context/global/context'
11
- import { GuardHeader } from '../../../components/AuthingGuard/Header'
12
- import { MfaLayout } from '../../../components/AuthingGuard/MfaLayout'
13
- import { LoginLayout } from '../../../components/AuthingGuard/LoginLayout'
14
- import {
15
- defaultGuardConfig,
16
- HIDE_SOCIALS,
17
- } from '../../../components/AuthingGuard/constants'
18
- import { RegisterLayout } from '../../../components/AuthingGuard/RegisterLayout'
19
- import { ResetPwdLayout } from '../../../components/AuthingGuard/ResetPwdLayout'
20
- import {
21
- SessionData,
22
- trackSession,
23
- fetchAppConfig,
24
- ApplicationConfig,
25
- SocialConnectionItem,
26
- } from '../../../components/AuthingGuard/api'
27
- import {
28
- GuardMode,
29
- GuardScenes,
30
- GuardConfig,
31
- UserConfig,
32
- Lang,
33
- } from '../../../components/AuthingGuard/types'
34
-
35
- import './style.less'
36
- import { CompleteUserInfoLayout } from '../CompleteUserInfoLayout'
37
- import { AppMfaLayout } from '../AppMFALayout'
38
- import { IconFont } from '../IconFont'
39
- import { ToggleLang } from '../ToggleLang'
40
- import { useTranslation } from 'react-i18next'
41
- import i18n from 'i18next'
42
- import { changeLang } from '../../_utils/locales'
43
-
44
- const checkConfig = (appId: string) => {
45
- // 不要去掉 console.warn,不然 vue 版打包出来每次都会 throw error,估计是 rollup 打包有问题
46
- if (!appId) {
47
- console.warn('APP ID: ', appId)
48
- throw new Error(i18n.t('common.unAppId'))
49
- }
50
- }
51
-
52
- const useGuardConfig = () => {
53
- const {
54
- state: { appId, userConfig },
55
- setValue,
56
- } = useGuardContext()
57
-
58
- const { t } = useTranslation()
59
-
60
- const [loading, setLoading] = useState(true)
61
-
62
- const [appConfig, setAppConfig] = useState<Partial<ApplicationConfig>>({})
63
- const [errorMsg, setErrorMsg] = useState('')
64
- const [errorDetail, setErrorDetail] = useState<any>()
65
-
66
- useEffect(() => {
67
- try {
68
- checkConfig(appId)
69
-
70
- setErrorDetail(null)
71
- setErrorMsg('')
72
- } catch (e: any) {
73
- setErrorDetail(e)
74
- setErrorMsg(e.message)
75
- console.error(e)
76
- }
77
- }, [appId])
78
-
79
- // 获取应用配置
80
- useEffect(() => {
81
- setLoading(true)
82
-
83
- if (!appId) {
84
- setLoading(false)
85
- return
86
- }
87
- fetchAppConfig(appId)
88
- .then((res) => {
89
- if (res.code !== 200) {
90
- setErrorMsg(res.message!)
91
- setErrorDetail(res)
92
- return
93
- }
94
-
95
- setAppConfig(res.data!)
96
- setValue('userPoolId', res.data?.userPoolId)
97
- })
98
- .catch((e: any) => {
99
- setErrorDetail(e)
100
- setErrorMsg(t('common.networkError'))
101
- })
102
- .finally(() => {
103
- setLoading(false)
104
- })
105
-
106
- // eslint-disable-next-line react-hooks/exhaustive-deps
107
- }, [appId])
108
-
109
- useEffect(() => {
110
- // 先移除之前的
111
- removeStyles('appConfig')
112
- removeStyles('userConfig')
113
-
114
- insertStyles(appConfig?.css, 'appConfig')
115
- insertStyles(userConfig.contentCss, 'userConfig')
116
- }, [appConfig, userConfig.contentCss])
117
-
118
- const guardConfig = useMemo<GuardConfig>(() => {
119
- /**
120
- * 将用应用配置与用户手动传入的配置合并
121
- * 优先级:用户传入 > 应用 > 用户池
122
- */
123
-
124
- // 社会化登录
125
- let socialConnectionObjs: SocialConnectionItem[] | undefined
126
- // 默认展示所有社会化登录
127
- if (!userConfig.socialConnections) {
128
- socialConnectionObjs = [...(appConfig.socialConnections || [])]
129
- } else {
130
- const socials = userConfig.socialConnections
131
- socialConnectionObjs = appConfig.socialConnections?.filter?.((item) =>
132
- socials.includes(item.provider)
133
- )
134
- }
135
-
136
- // 某些社会化登录会在 tabs 中显示,或者无法在 Guard 中使用,所以底部不显示了
137
- socialConnectionObjs = socialConnectionObjs?.filter(
138
- (item) => !HIDE_SOCIALS.includes(item.provider)
139
- )
140
-
141
- // 企业身份源
142
- let enterpriseConnectionObjs: ApplicationConfig['identityProviders']
143
-
144
- if (userConfig.enterpriseConnections) {
145
- enterpriseConnectionObjs =
146
- appConfig.identityProviders?.filter?.((item) =>
147
- userConfig.enterpriseConnections!.includes(item.identifier)
148
- ) || []
149
- } else {
150
- enterpriseConnectionObjs = appConfig.identityProviders || []
151
- }
152
-
153
- // 登录方式
154
- const loginMethods =
155
- userConfig.loginMethods ||
156
- appConfig.loginTabs?.list ||
157
- defaultGuardConfig.loginMethods
158
-
159
- // 账密登录的登录拆分
160
- const passwordLoginMethods =
161
- userConfig.passwordLoginMethods ||
162
- appConfig.passwordTabConfig?.enabledLoginMethods ||
163
- defaultGuardConfig.loginMethods
164
-
165
- // 默认登录方式
166
- const defaultLoginMethod =
167
- userConfig.defaultLoginMethod ||
168
- appConfig.loginTabs?.default ||
169
- defaultGuardConfig.defaultLoginMethod
170
-
171
- // 注册方式
172
- const registerMethods =
173
- userConfig.registerMethods ||
174
- appConfig.registerTabs?.list ||
175
- defaultGuardConfig.registerMethods
176
- // 默认注册方式
177
- const defaultRegisterMethod =
178
- userConfig.defaultRegisterMethod ||
179
- appConfig.registerTabs?.default ||
180
- defaultGuardConfig.defaultRegisterMethod
181
-
182
- // 应用名
183
- const title = loading
184
- ? ''
185
- : userConfig.title ?? appConfig.name ?? defaultGuardConfig.title
186
-
187
- // 应用 logo
188
- const logo = loading
189
- ? ''
190
- : userConfig.logo ?? appConfig.logo ?? defaultGuardConfig.logo
191
-
192
- // 是否自动注册
193
- const autoRegister =
194
- userConfig.autoRegister ??
195
- appConfig.ssoPageComponentDisplay?.autoRegisterThenLoginHintInfo ??
196
- defaultGuardConfig.autoRegister
197
-
198
- // 禁止注册
199
- const disableRegister =
200
- userConfig.disableRegister ??
201
- !(
202
- appConfig.ssoPageComponentDisplay?.registerBtn ??
203
- !defaultGuardConfig.disableRegister
204
- )
205
-
206
- // 禁止重置密码
207
- const disableResetPwd =
208
- userConfig.disableResetPwd ??
209
- !(
210
- appConfig.ssoPageComponentDisplay?.registerBtn ??
211
- !defaultGuardConfig.disableResetPwd
212
- )
213
-
214
- return deepMerge<GuardConfig>(
215
- {} as GuardConfig,
216
- defaultGuardConfig,
217
- userConfig,
218
- {
219
- logo,
220
- title,
221
- autoRegister,
222
- loginMethods,
223
- passwordLoginMethods,
224
- extendsFields: appConfig.extendsFields,
225
- disableRegister,
226
- disableResetPwd,
227
- registerMethods,
228
- defaultLoginMethod,
229
- socialConnectionObjs,
230
- defaultRegisterMethod,
231
- enterpriseConnectionObjs,
232
- publicKey: appConfig.publicKey,
233
- agreementEnabled: appConfig.agreementEnabled,
234
- agreements: appConfig.agreements,
235
- }
236
- )
237
- }, [
238
- userConfig,
239
- appConfig.loginTabs?.list,
240
- appConfig.loginTabs?.default,
241
- appConfig.passwordTabConfig?.enabledLoginMethods,
242
- appConfig.registerTabs?.list,
243
- appConfig.registerTabs?.default,
244
- appConfig.name,
245
- appConfig.logo,
246
- appConfig.ssoPageComponentDisplay?.autoRegisterThenLoginHintInfo,
247
- appConfig.ssoPageComponentDisplay?.registerBtn,
248
- appConfig.extendsFields,
249
- appConfig.publicKey,
250
- appConfig.agreementEnabled,
251
- appConfig.agreements,
252
- appConfig.socialConnections,
253
- appConfig.identityProviders,
254
- loading,
255
- ])
256
-
257
- return {
258
- loading,
259
- errorMsg,
260
- guardConfig,
261
- errorDetail,
262
- }
263
- }
264
-
265
- const useModal = (visible?: boolean) => {
266
- const {
267
- state: { userConfig },
268
- } = useGuardContext()
269
-
270
- const isModal = userConfig.mode === GuardMode.Modal
271
- // 传入了 visible 则为受控组件
272
- const isControlled = typeof visible !== 'undefined'
273
-
274
- // modal 模式,没传 visible,默认为 true
275
- const [localVisible, setLocalVisible] = useState(
276
- isModal && isControlled ? visible : true
277
- )
278
-
279
- const toggleLocalVisible = () => {
280
- setLocalVisible((v) => !v)
281
- }
282
-
283
- const realVisible = useMemo(() => {
284
- return isControlled ? visible : localVisible
285
- }, [isControlled, localVisible, visible])
286
-
287
- return {
288
- isModal,
289
- realVisible,
290
- isControlled,
291
- toggleLocalVisible,
292
- }
293
- }
294
-
295
- export const GuardLayout: FC<{
296
- visible?: boolean
297
- className?: string
298
- id?: string
299
- style?: React.CSSProperties
300
- lang?: Lang
301
- // 这个传下是为了响应 config 变化,好蠢,以后优化
302
- userConfig: UserConfig
303
- }> = ({
304
- visible,
305
- id,
306
- className,
307
- style,
308
- lang,
309
- userConfig: reactiveUserConfig,
310
- }) => {
311
- const { t } = useTranslation()
312
- const {
313
- state: { guardScenes, authClient, guardEvents, activeTabs, localesConfig },
314
- setValue,
315
- } = useGuardContext()
316
-
317
- const { realVisible, isControlled, toggleLocalVisible } = useModal(visible)
318
-
319
- const { loading, errorMsg, guardConfig, errorDetail } = useGuardConfig()
320
-
321
- useEffect(() => {
322
- if (lang) {
323
- authClient.setLang(lang)
324
- changeLang(lang)
325
- }
326
- }, [authClient, lang])
327
-
328
- useEffect(() => {
329
- if (!loading) {
330
- guardEvents.onLoginTabChange?.(activeTabs.login)
331
- }
332
- }, [activeTabs.login, loading, guardEvents])
333
-
334
- useEffect(() => {
335
- if (!loading) {
336
- guardEvents.onRegisterTabChange?.(activeTabs.register)
337
- }
338
- }, [activeTabs.register, loading, guardEvents])
339
-
340
- useEffect(() => {
341
- setValue('userConfig', reactiveUserConfig)
342
- }, [reactiveUserConfig, setValue])
343
-
344
- // 动画完成后完全隐藏 dom
345
- const [hidden, setHidden] = useState(false)
346
- useEffect(() => {
347
- setHidden(false)
348
- }, [realVisible])
349
-
350
- const closeHandler = useCallback(() => {
351
- if (!isControlled && realVisible) {
352
- toggleLocalVisible()
353
- }
354
- guardEvents.onClose?.()
355
- }, [isControlled, guardEvents, toggleLocalVisible, realVisible])
356
-
357
- useEffect(() => {
358
- if (loading) {
359
- return
360
- }
361
- if (errorDetail) {
362
- guardEvents.onLoadError?.(errorDetail)
363
- return
364
- }
365
-
366
- guardEvents.onLoad?.(authClient)
367
- }, [authClient, errorDetail, guardEvents, loading, t])
368
-
369
- useEffect(() => {
370
- if (guardConfig.isSSO) {
371
- trackSession().then((sessionData) => {
372
- // 这个接口没有 code, data, 直接返回了数据
373
- let typedData = (sessionData as unknown) as SessionData
374
- if (typedData.userInfo) {
375
- message.success(t('common.LoginSuccess'))
376
- guardEvents.onLogin?.(typedData.userInfo, authClient)
377
- }
378
- })
379
- }
380
- }, [guardConfig.isSSO, guardEvents, authClient, t])
381
-
382
- useEffect(() => {
383
- setValue('config', guardConfig)
384
- setValue('activeTabs', {
385
- [GuardScenes.Login]: guardConfig.defaultLoginMethod,
386
- [GuardScenes.Register]: guardConfig.defaultRegisterMethod,
387
- })
388
- // eslint-disable-next-line react-hooks/exhaustive-deps
389
- }, [guardConfig])
390
-
391
- const isModal = useMemo(() => guardConfig.mode === GuardMode.Modal, [
392
- guardConfig,
393
- ])
394
-
395
- // 监听 esc 关闭 modal
396
- useEffect(() => {
397
- const handler = (evt: KeyboardEvent) => {
398
- if (evt.keyCode === 27 && isModal && guardConfig.escCloseable) {
399
- closeHandler()
400
- }
401
- }
402
-
403
- window.addEventListener('keydown', handler)
404
- return () => window.removeEventListener('keydown', handler)
405
- }, [closeHandler, guardConfig, isModal])
406
-
407
- const layoutMap = {
408
- [GuardScenes.Login]: <LoginLayout />,
409
- [GuardScenes.Register]: <RegisterLayout />,
410
- [GuardScenes.RestPassword]: <ResetPwdLayout />,
411
- [GuardScenes.MfaVerify]: <MfaLayout />,
412
- [GuardScenes.CompleteUserInfo]: <CompleteUserInfoLayout />,
413
- [GuardScenes.AppMfaVerify]: <AppMfaLayout />,
414
- }
415
-
416
- return (
417
- <div
418
- id={id}
419
- style={{
420
- ...style,
421
- zIndex: guardConfig.zIndex || 100,
422
- }}
423
- className={getClassnames([
424
- 'authing-guard-layout',
425
- !realVisible && 'authing-guard-layout__hidden',
426
- isModal && 'authing-guard-layout__modal',
427
- hidden && 'authing-guard-layout__dis-none',
428
- className,
429
- ])}
430
- onTransitionEnd={() => {
431
- if (!realVisible) {
432
- setHidden(true)
433
- }
434
- }}
435
- >
436
- <>
437
- {isModal && (
438
- <div
439
- className={getClassnames([
440
- 'authing-guard-mask',
441
- !realVisible && 'authing-guard-mask__hidden',
442
- ])}
443
- ></div>
444
- )}
445
- <div
446
- className={getClassnames([
447
- 'authing-guard-container',
448
- !realVisible && 'authing-guard-container__hidden',
449
- ])}
450
- >
451
- {isModal && guardConfig.clickCloseable && (
452
- <button onClick={closeHandler} className="authing-guard-close-btn">
453
- <IconFont type="authing-guanbi" />
454
- </button>
455
- )}
456
-
457
- <GuardHeader />
458
-
459
- {loading ? (
460
- <Spin size="large" className="authing-guard-loading" />
461
- ) : errorMsg ? (
462
- <div className="authing-guard-load-error">{errorMsg}</div>
463
- ) : (
464
- layoutMap[guardScenes]
465
- )}
466
- {/* <div>{localesConfig?.isShowChange && <ToggleLang />}</div> */}
467
- <div>
468
- {localesConfig?.isShowChange === false ? null : <ToggleLang />}
469
- </div>
470
- </div>
471
- </>
472
- </div>
473
- )
474
- }
@@ -1,111 +0,0 @@
1
- .authing-guard-layout {
2
- display: flex;
3
- justify-content: center;
4
- align-items: center;
5
- width: 100%;
6
- padding: 24px 0;
7
- height: 100%;
8
- }
9
-
10
- .authing-guard-layout__hidden {
11
- pointer-events: none;
12
- }
13
-
14
- .authing-guard-layout__dis-none {
15
- z-index: -1;
16
- opacity: 0;
17
- }
18
-
19
- .authing-guard-layout__modal {
20
- position: fixed;
21
- left: 0;
22
- top: 0;
23
- }
24
-
25
- .authing-guard-mask {
26
- position: absolute;
27
- left: 0;
28
- right: 0;
29
- top: 0;
30
- bottom: 0;
31
- background-color: rgba(0, 0, 0, 0.45);
32
- opacity: 1;
33
- transition: all 0.3s;
34
- }
35
-
36
- .authing-guard-mask__hidden {
37
- opacity: 0;
38
- }
39
-
40
- .authing-guard-container {
41
- width: 440px;
42
- min-height: 610px;
43
- max-height: 100%;
44
- box-sizing: border-box;
45
- background-color: #fff;
46
- padding: 39px 38px 31px;
47
- border-radius: 10px;
48
- display: flex;
49
- flex-direction: column;
50
- box-shadow: 0 2px 10px 0 rgba(57, 106, 255, 0.2);
51
- margin-left: auto;
52
- margin-right: auto;
53
- overflow: auto;
54
- position: relative;
55
- transform: translateY(0);
56
- transition: all 0.3s;
57
- }
58
-
59
- .authing-guard-container__hidden {
60
- transform: translateY(2000px);
61
- }
62
-
63
- .authing-guard-loading,
64
- .authing-guard-load-error {
65
- flex: 1;
66
- display: flex;
67
- align-items: center;
68
- justify-content: center;
69
- }
70
-
71
- .authing-guard-close-btn {
72
- position: absolute;
73
- right: 12px;
74
- top: 12px;
75
- border: none;
76
- outline: none;
77
- box-shadow: none;
78
- background-color: #fff;
79
- border-radius: 50%;
80
- width: 30px;
81
- height: 30px;
82
- text-align: center;
83
- line-height: 20px;
84
- cursor: pointer;
85
- &:focus {
86
- outline: none;
87
- border: none;
88
- box-shadow: none;
89
- }
90
- &:hover {
91
- color: #396aff;
92
- }
93
- }
94
-
95
- @media only screen and (max-width: 719px) {
96
- .authing-guard-layout {
97
- padding: 0;
98
- }
99
- .authing-guard-container {
100
- width: 100%;
101
- min-height: 100%;
102
- border: none;
103
- border-radius: initial;
104
- box-shadow: initial;
105
- padding-left: 24px;
106
- padding-right: 24px;
107
- }
108
- .authing-ant-input {
109
- font-size: 14px;
110
- }
111
- }
@@ -1,25 +0,0 @@
1
- import React, { FC } from 'react'
2
- import { Avatar } from 'antd'
3
-
4
- import { useGuardContext } from '../../context/global/context'
5
-
6
- import './style.less'
7
-
8
- export interface HeaderProps extends React.HTMLAttributes<HTMLDivElement> {}
9
-
10
- export const GuardHeader: FC<HeaderProps> = (props) => {
11
- const {
12
- state: {
13
- config: { logo, title },
14
- },
15
- } = useGuardContext()
16
-
17
- return (
18
- <div className="authing-guard-header">
19
- {Boolean(logo) && (
20
- <Avatar className="authing-guard-logo" src={logo} size={50}></Avatar>
21
- )}
22
- <div className="authing-guard-title">{title}</div>
23
- </div>
24
- )
25
- }
@@ -1,52 +0,0 @@
1
- .authing-guard-header {
2
- display: flex;
3
- flex-direction: column;
4
- justify-content: center;
5
- align-items: center;
6
- }
7
-
8
- .authing-guard-logo {
9
- margin-bottom: 8px;
10
- }
11
-
12
- .authing-guard-logo img {
13
- object-fit: contain;
14
- }
15
-
16
- .authing-guard-title {
17
- color: #abb9d7;
18
- font-size: 24px;
19
- margin-bottom: 24px;
20
- width: 100%;
21
- word-break: break-all;
22
- text-align: center;
23
- }
24
-
25
- // .large .logo {
26
- // margin-bottom: 16px;
27
- // }
28
-
29
- // .large .title {
30
- // color: #333333;
31
- // font-size: 32px;
32
- // }
33
-
34
- @media only screen and (max-width: 719px) {
35
- .authing-guard-header {
36
- align-items: flex-start;
37
- flex-direction: row;
38
- align-items: center;
39
- justify-content: flex-start;
40
- padding-top: 40px;
41
- padding-bottom: 48px;
42
- }
43
- .authing-guard-title {
44
- margin-bottom: 0;
45
- padding-left: 8px;
46
- color: #333333;
47
- font-weight: 500;
48
- }
49
- .authing-guard-logo {
50
- margin: 0;
51
- }
52
- }