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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/dist/index.min.css +2 -0
  2. package/dist/index.min.js +2 -0
  3. package/dist/index.min.js.LICENSE.txt +71 -0
  4. package/{components/ShieldSpin/loading.svg → dist/static/media/loading.4a67a5f3.svg} +0 -0
  5. package/lib/index.d.ts +2108 -118
  6. package/lib/index.min.css +2 -2
  7. package/lib/index.min.js +1 -1
  8. package/lib/index.min.js.LICENSE.txt +2 -0
  9. package/package.json +32 -10
  10. package/.eslintignore +0 -6
  11. package/.eslintrc.js +0 -7
  12. package/.prettierrc +0 -5
  13. package/.vscode/settings.json +0 -31
  14. package/build/favicon.ico +0 -0
  15. package/build/logo192.png +0 -0
  16. package/build/logo512.png +0 -0
  17. package/build/manifest.json +0 -25
  18. package/build/robots.txt +0 -3
  19. package/components/AuthingDropdown/index.tsx +0 -52
  20. package/components/AuthingDropdown/style.less +0 -43
  21. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  22. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  23. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  24. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  25. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  26. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  27. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  28. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  29. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  30. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  31. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  32. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  33. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  34. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  35. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  36. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  37. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  38. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  39. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  40. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  41. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  42. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  43. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  44. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  45. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  46. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  47. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  48. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  49. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  50. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  51. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  52. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  53. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  54. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  55. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  56. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  57. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  58. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  59. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  60. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  61. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  62. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  63. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  64. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  65. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  66. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  67. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  68. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  69. package/components/AuthingGuard/Forms/index.ts +0 -13
  70. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  71. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  72. package/components/AuthingGuard/Header/index.tsx +0 -25
  73. package/components/AuthingGuard/Header/style.less +0 -52
  74. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  75. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  76. package/components/AuthingGuard/IconFont/style.less +0 -6
  77. package/components/AuthingGuard/IconFont/svg.js +0 -2
  78. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  79. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  80. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  81. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  82. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  83. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  84. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  85. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  86. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  87. package/components/AuthingGuard/api/appConfig.ts +0 -146
  88. package/components/AuthingGuard/api/index.ts +0 -3
  89. package/components/AuthingGuard/api/sso.ts +0 -29
  90. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  91. package/components/AuthingGuard/constants.ts +0 -105
  92. package/components/AuthingGuard/hooks/index.tsx +0 -70
  93. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  94. package/components/AuthingGuard/index.tsx +0 -126
  95. package/components/AuthingGuard/style.less +0 -103
  96. package/components/AuthingGuard/types/Forms.ts +0 -94
  97. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  98. package/components/AuthingGuard/types/GuardState.ts +0 -7
  99. package/components/AuthingGuard/types/Locales.ts +0 -12
  100. package/components/AuthingGuard/types/index.ts +0 -4
  101. package/components/AuthingTabs/index.tsx +0 -98
  102. package/components/AuthingTabs/style.less +0 -135
  103. package/components/BindTotp/core/bindSuccess.tsx +0 -61
  104. package/components/BindTotp/core/securityCode.tsx +0 -119
  105. package/components/BindTotp/index.tsx +0 -134
  106. package/components/BindTotp/props.ts +0 -30
  107. package/components/BindTotp/styles.less +0 -56
  108. package/components/ChangeLanguage/index.tsx +0 -35
  109. package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
  110. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  111. package/components/ChangePassword/index.tsx +0 -59
  112. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  113. package/components/CompleteInfo/index.tsx +0 -45
  114. package/components/CompleteInfo/props.ts +0 -40
  115. package/components/CompleteInfo/styles.less +0 -7
  116. package/components/CompleteUserInfo/index.tsx +0 -49
  117. package/components/CompleteUserInfo/props.ts +0 -25
  118. package/components/ComponentsRender/index.back +0 -64
  119. package/components/CopyAbleText/index.tsx +0 -54
  120. package/components/CopyAbleText/style.less +0 -13
  121. package/components/DownloadAuthenticator/index.tsx +0 -97
  122. package/components/DownloadAuthenticator/props.ts +0 -22
  123. package/components/DownloadAuthenticator/styles.less +0 -52
  124. package/components/ForgetPassword/core/resetPassword.tsx +0 -150
  125. package/components/ForgetPassword/index.tsx +0 -51
  126. package/components/Guard/Guard.tsx +0 -226
  127. package/components/Guard/authClient.ts +0 -55
  128. package/components/Guard/config.ts +0 -19
  129. package/components/Guard/event.ts +0 -18
  130. package/components/Guard/index.tsx +0 -10
  131. package/components/Guard/module.ts +0 -19
  132. package/components/Guard/stateMachine.ts +0 -133
  133. package/components/Guard/styles.less +0 -444
  134. package/components/IconFont/iconfont.js +0 -74
  135. package/components/IconFont/index.tsx +0 -16
  136. package/components/IconFont/style.less +0 -6
  137. package/components/IconFont/svg.js +0 -2
  138. package/components/ImagePro/index.tsx +0 -52
  139. package/components/ImagePro/styles.less +0 -40
  140. package/components/Login/codemap.ts +0 -35
  141. package/components/Login/core/withAD.tsx +0 -9
  142. package/components/Login/core/withAppQrcode.tsx +0 -49
  143. package/components/Login/core/withLDAP.tsx +0 -145
  144. package/components/Login/core/withPassword.tsx +0 -176
  145. package/components/Login/core/withPhonecode.tsx +0 -135
  146. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  147. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  148. package/components/Login/index.tsx +0 -359
  149. package/components/Login/props.ts +0 -90
  150. package/components/Login/socialLogin/index.tsx +0 -413
  151. package/components/Login/socialLogin/style.less +0 -61
  152. package/components/Login/styles.less +0 -53
  153. package/components/MFA/codemap.ts +0 -21
  154. package/components/MFA/core/email.tsx +0 -226
  155. package/components/MFA/core/face.tsx +0 -297
  156. package/components/MFA/core/face_deps.tsx +0 -37
  157. package/components/MFA/core/sms.tsx +0 -222
  158. package/components/MFA/core/totp.tsx +0 -137
  159. package/components/MFA/index.tsx +0 -135
  160. package/components/MFA/mfaMethods/index.tsx +0 -81
  161. package/components/MFA/mfaMethods/style.less +0 -39
  162. package/components/MFA/props.ts +0 -51
  163. package/components/MFA/styles.less +0 -92
  164. package/components/NeedHelpView/core/describeQuestions.tsx +0 -227
  165. package/components/NeedHelpView/index.tsx +0 -99
  166. package/components/RecoveryCode/core/useCode.tsx +0 -71
  167. package/components/RecoveryCode/index.tsx +0 -27
  168. package/components/RecoveryCode/interface.ts +0 -31
  169. package/components/RecoveryCode/style.less +0 -13
  170. package/components/Register/codemap.ts +0 -16
  171. package/components/Register/components/Agreements/index.tsx +0 -81
  172. package/components/Register/components/Agreements/style.less +0 -44
  173. package/components/Register/core/WithEmail.tsx +0 -250
  174. package/components/Register/core/WithPhone.tsx +0 -190
  175. package/components/Register/index.tsx +0 -122
  176. package/components/Register/props.ts +0 -50
  177. package/components/SendCode/SendCodeBtn.tsx +0 -96
  178. package/components/SendCode/index.tsx +0 -98
  179. package/components/SendCode/style.less +0 -31
  180. package/components/ShieldSpin/index.tsx +0 -27
  181. package/components/SubmitButton/index.tsx +0 -50
  182. package/components/Type/index.ts +0 -61
  183. package/components/VerifyCodeInput/index.tsx +0 -76
  184. package/components/VerifyCodeInput/style.less +0 -24
  185. package/components/_utils/GuardErrorCode.ts +0 -8
  186. package/components/_utils/clipboard.ts +0 -27
  187. package/components/_utils/config.ts +0 -123
  188. package/components/_utils/guradHttp.ts +0 -93
  189. package/components/_utils/hooks/index.ts +0 -56
  190. package/components/_utils/http.ts +0 -85
  191. package/components/_utils/index.ts +0 -310
  192. package/components/_utils/locales/en/common.json +0 -218
  193. package/components/_utils/locales/en/index.ts +0 -6
  194. package/components/_utils/locales/en/login.json +0 -95
  195. package/components/_utils/locales/en/map.json +0 -4
  196. package/components/_utils/locales/en/user.json +0 -82
  197. package/components/_utils/locales/index.ts +0 -45
  198. package/components/_utils/locales/zh/common.json +0 -218
  199. package/components/_utils/locales/zh/index.ts +0 -6
  200. package/components/_utils/locales/zh/login.json +0 -95
  201. package/components/_utils/locales/zh/map.json +0 -4
  202. package/components/_utils/locales/zh/user.json +0 -82
  203. package/components/_utils/popupCenter.ts +0 -48
  204. package/components/context/base.tsx +0 -28
  205. package/components/context/global/context.tsx +0 -39
  206. package/components/context/global/reducer.tsx +0 -56
  207. package/components/context/module/context.tsx +0 -23
  208. package/components/index.ts +0 -10
  209. package/config/antdReplacer.js +0 -51
  210. package/config/env.js +0 -104
  211. package/config/getHttpsConfig.js +0 -66
  212. package/config/jest/cssTransform.js +0 -14
  213. package/config/jest/fileTransform.js +0 -40
  214. package/config/modules.js +0 -134
  215. package/config/paths.js +0 -71
  216. package/config/pnpTs.js +0 -35
  217. package/config/webpack.config.js +0 -835
  218. package/config/webpackDevServer.config.js +0 -130
  219. package/examples.tsx +0 -100
  220. package/index.js +0 -1
  221. package/logo.svg +0 -7
  222. package/public/favicon.ico +0 -0
  223. package/public/index.html +0 -43
  224. package/public/logo192.png +0 -0
  225. package/public/logo512.png +0 -0
  226. package/public/manifest.json +0 -25
  227. package/public/robots.txt +0 -3
  228. package/react-app-env.d.ts +0 -71
  229. package/reportWebVitals.ts +0 -15
  230. package/scripts/build.js +0 -208
  231. package/scripts/lib.js +0 -200
  232. package/scripts/start.js +0 -162
  233. package/scripts/test.js +0 -49
  234. package/setupTests.ts +0 -5
  235. package/tsconfig.json +0 -30
@@ -1,359 +0,0 @@
1
- import React, { useEffect, useState } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { message, Tabs } from 'antd'
4
- import { intersection } from 'lodash'
5
-
6
- import { LoginWithPassword } from './core/withPassword'
7
- import { LoginWithPhoneCode } from './core/withPhonecode'
8
- import { LoginWithLDAP } from './core/withLDAP'
9
- import { LoginWithAD } from './core/withAD'
10
- import { LoginWithAppQrcode } from './core/withAppQrcode'
11
- import { LoginWithWechatMiniQrcode } from './core/withWechatMiniQrcode'
12
- import { LoginWithWechatmpQrcode } from './core/withWechatmpQrcode'
13
- import { codeMap } from './codemap'
14
- import { SocialLogin } from './socialLogin'
15
- import { GuardLoginViewProps } from './props'
16
-
17
- import { useAuthClient } from '../Guard/authClient'
18
- import { GuardModuleType } from '../Guard/module'
19
- import { LoginMethods } from '../AuthingGuard/types'
20
- import { IconFont } from '../IconFont'
21
- import { ChangeLanguage } from '../ChangeLanguage'
22
- import { i18n } from '../_utils/locales'
23
-
24
- import './styles.less'
25
-
26
- const inputWays = [
27
- LoginMethods.Password,
28
- LoginMethods.PhoneCode,
29
- LoginMethods.AD,
30
- LoginMethods.LDAP,
31
- ]
32
- const qrcodeWays = [
33
- LoginMethods.AppQr,
34
- LoginMethods.WxMinQr,
35
- LoginMethods.WechatMpQrcode,
36
- ]
37
-
38
- const useMethods = (config: any) => {
39
- let dlm = config?.defaultLoginMethod
40
- let propsMethods = config?.loginMethods
41
-
42
- if (!propsMethods?.includes(dlm)) {
43
- dlm = propsMethods?.[0]
44
- }
45
- let renderInputWay = intersection(propsMethods, inputWays).length > 0
46
- let renderQrcodeWay = intersection(propsMethods, qrcodeWays).length > 0
47
- return [dlm, renderInputWay, renderQrcodeWay]
48
- }
49
-
50
- const useDisables = (data: any) => {
51
- let { disableResetPwd, disableRegister } = data.config
52
- let { loginWay, autoRegister } = data
53
-
54
- if (loginWay === LoginMethods.PhoneCode) {
55
- disableResetPwd = true
56
- }
57
- if (loginWay === LoginMethods.LDAP) {
58
- disableResetPwd = true
59
- disableRegister = true
60
- }
61
- if (autoRegister === true) {
62
- disableRegister = true
63
- }
64
- return { disableResetPwd, disableRegister }
65
- }
66
-
67
- const useSwitchStates = (loginWay: LoginMethods) => {
68
- let switchText = i18n.t('login.scanLogin')
69
- if (qrcodeWays.includes(loginWay)) {
70
- switchText = i18n.t('login.moreWays')
71
- }
72
- let inputNone = !inputWays.includes(loginWay) ? 'none' : ''
73
- let qrcodeNone = !qrcodeWays.includes(loginWay) ? 'none' : ''
74
-
75
- return { switchText, inputNone, qrcodeNone }
76
- }
77
- export const GuardLoginView = (props: GuardLoginViewProps) => {
78
- let [defaultMethod, renderInputWay, renderQrcodeWay] = useMethods(
79
- props.config
80
- )
81
- const { t } = useTranslation()
82
- const [loginWay, setLoginWay] = useState(defaultMethod)
83
- const [canLoop, setCanLoop] = useState(false) // 允许轮询
84
- const client = useAuthClient()
85
-
86
- let publicKey = props.config?.publicKey!
87
- // let autoRegister = props.config?.autoRegister
88
- let ms = props.config?.loginMethods
89
- let { autoRegister, langRange } = props.config
90
-
91
- let { disableResetPwd, disableRegister } = useDisables({
92
- config: props.config,
93
- loginWay,
94
- autoRegister,
95
- })
96
-
97
- const __codePaser = (code: number) => {
98
- const action = codeMap[code]
99
- if (code === 200) {
100
- return (data: any) => {
101
- props.onLogin?.(data, client!) // 登录成功
102
- }
103
- }
104
-
105
- if (!action) {
106
- return () => {
107
- console.error('未捕获 code', code)
108
- // props.onLoginError?.(data, client) // 未捕获 code
109
- }
110
- }
111
-
112
- // 解析成功
113
- if (action?.action === 'changeModule') {
114
- let m = action.module ? action.module : GuardModuleType.ERROR
115
- let init = action.initData ? action.initData : {}
116
- return (initData?: any) =>
117
- props.__changeModule?.(m, { ...initData, ...init })
118
- }
119
- if (action?.action === 'message') {
120
- return (initData?: any) => {
121
- // props.onLoginError?.(data, client!) // 未捕获 code
122
- message.error(initData?.__message)
123
- }
124
- }
125
-
126
- // 最终结果
127
- return () => {
128
- // props.onLoginError?.(data, client!) // 未捕获 code
129
- console.error('last action at loginview')
130
- }
131
- }
132
-
133
- const onLogin = (code: any, data: any, message?: string) => {
134
- const callback = __codePaser?.(code)
135
- if (!data) {
136
- data = {}
137
- }
138
- data.__message = message
139
- callback?.(data)
140
- }
141
-
142
- const onBeforeLogin = (loginInfo: any) => {
143
- if (props.onBeforeLogin) {
144
- return props.onBeforeLogin?.(loginInfo, client)
145
- }
146
- return () => console.log('Guard not onBeforeLogin hooks')
147
- }
148
-
149
- useEffect(() => {
150
- if (qrcodeWays.includes(loginWay)) {
151
- setCanLoop(true)
152
- }
153
- // 可以设定 = fasle 的时候关闭 qrcode 的几个定时器
154
- // 不关的话,第二次进入会更快,也没什么代价(只有轮询)
155
- }, [loginWay])
156
-
157
- let { switchText, inputNone, qrcodeNone } = useSwitchStates(loginWay)
158
- // if (loading) {
159
- // return (
160
- // <div className="g2-view-container">
161
- // <LoadShielding />
162
- // </div>
163
- // )
164
- // }
165
- return (
166
- <div className="g2-view-container">
167
- {/* 两种方式都需要渲染的时候,才出现切换按钮 */}
168
- {renderInputWay && renderQrcodeWay && (
169
- <div className="g2-qrcode-switch">
170
- <div className="switch-text">{switchText}</div>
171
- <div
172
- className="switch-img"
173
- onClick={() => {
174
- if (inputWays.includes(loginWay)) {
175
- setLoginWay(LoginMethods.WxMinQr)
176
- } else if (qrcodeWays.includes(loginWay)) {
177
- setLoginWay(LoginMethods.Password)
178
- }
179
- }}
180
- >
181
- <div className="imgae-mask" />
182
- <IconFont
183
- type="authing-a-erweima22"
184
- className={`qrcode-switch-image ${inputNone}`}
185
- />
186
- <IconFont
187
- type="authing-diannao"
188
- className={`qrcode-switch-image ${qrcodeNone}`}
189
- />
190
- </div>
191
- </div>
192
- )}
193
-
194
- <div className="g2-view-header">
195
- <img src={props.config?.logo} alt="" className="icon" />
196
- <div className="title">
197
- {t('common.login')} {props.config?.title}
198
- </div>
199
- </div>
200
-
201
- {renderInputWay && (
202
- <div className={inputNone}>
203
- <div className={`g2-view-tabs`}>
204
- <Tabs
205
- onChange={(k: any) => {
206
- setLoginWay(k)
207
- // props.onLoginTabChange?.(k)
208
- }}
209
- activeKey={loginWay}
210
- >
211
- {ms?.includes(LoginMethods.Password) && (
212
- <Tabs.TabPane
213
- key={LoginMethods.Password}
214
- tab={t('login.pwdLogin')}
215
- >
216
- <LoginWithPassword
217
- publicKey={publicKey}
218
- autoRegister={autoRegister}
219
- host={props.config.host}
220
- onLogin={onLogin}
221
- onBeforeLogin={onBeforeLogin}
222
- />
223
- </Tabs.TabPane>
224
- )}
225
- {ms?.includes(LoginMethods.PhoneCode) && (
226
- <Tabs.TabPane
227
- key={LoginMethods.PhoneCode}
228
- tab={t('login.verifyCodeLogin')}
229
- >
230
- <LoginWithPhoneCode
231
- autoRegister={autoRegister}
232
- onBeforeLogin={onBeforeLogin}
233
- onLogin={onLogin}
234
- />
235
- </Tabs.TabPane>
236
- )}
237
- {ms?.includes(LoginMethods.LDAP) && (
238
- <Tabs.TabPane
239
- key={LoginMethods.LDAP}
240
- tab={t('login.ldapLogin')}
241
- >
242
- <LoginWithLDAP
243
- publicKey={publicKey}
244
- autoRegister={autoRegister}
245
- host={props.config.host}
246
- onLogin={onLogin}
247
- onBeforeLogin={onBeforeLogin}
248
- />
249
- </Tabs.TabPane>
250
- )}
251
- {ms?.includes(LoginMethods.AD) && (
252
- <Tabs.TabPane key={LoginMethods.AD} tab={t('login.adLogin')}>
253
- <LoginWithAD onLogin={onLogin} />
254
- </Tabs.TabPane>
255
- )}
256
- </Tabs>
257
- </div>
258
- <div className={`g2-tips-line`}>
259
- {!disableResetPwd && (
260
- <div>
261
- <span
262
- className="link-like"
263
- onClick={() =>
264
- props.__changeModule?.(GuardModuleType.FORGET_PWD, {})
265
- }
266
- >
267
- {t('login.forgetPwd')}
268
- </span>
269
- <span style={{ margin: '0 4px' }} className="gray">
270
-
271
- </span>
272
- </div>
273
- )}
274
-
275
- <div
276
- className="touch-tip"
277
- onClick={() =>
278
- props.__changeModule?.(GuardModuleType.ANY_QUESTIONS, {})
279
- }
280
- >
281
- <IconFont
282
- type={'authing-a-question-line1'}
283
- // style={{ fontSize: 20, marginRight: 8 }}
284
- />
285
- </div>
286
-
287
- {!disableRegister && (
288
- <span className="go-to-register">
289
- <span className="gray">{t('common.noAccYet')}</span>
290
- <span
291
- className="link-like"
292
- onClick={() =>
293
- props.__changeModule?.(GuardModuleType.REGISTER, {})
294
- }
295
- >
296
- {t('common.registerImmediate')}
297
- </span>
298
- </span>
299
- )}
300
- </div>
301
- </div>
302
- )}
303
- {renderQrcodeWay && (
304
- <div className={`g2-view-tabs ${qrcodeNone}`}>
305
- <Tabs
306
- onChange={(k: any) => {
307
- props.onLoginTabChange?.(k)
308
- }}
309
- >
310
- {ms?.includes(LoginMethods.WxMinQr) && (
311
- <Tabs.TabPane
312
- key={LoginMethods.WxMinQr}
313
- tab={t('login.scanLogin')}
314
- >
315
- <LoginWithWechatMiniQrcode
316
- onLogin={onLogin}
317
- canLoop={canLoop}
318
- qrCodeScanOptions={props.config.qrCodeScanOptions}
319
- />
320
- </Tabs.TabPane>
321
- )}
322
- {ms?.includes(LoginMethods.AppQr) && (
323
- <Tabs.TabPane
324
- key={LoginMethods.AppQr}
325
- tab={t('login.appScanLogin')}
326
- >
327
- <LoginWithAppQrcode
328
- onLogin={onLogin}
329
- canLoop={canLoop}
330
- qrCodeScanOptions={props.config.qrCodeScanOptions}
331
- />
332
- </Tabs.TabPane>
333
- )}
334
- {ms?.includes(LoginMethods.WechatMpQrcode) && (
335
- <Tabs.TabPane
336
- key={LoginMethods.WechatMpQrcode}
337
- tab={t('login.wechatmpQrcode')}
338
- >
339
- <LoginWithWechatmpQrcode
340
- onLogin={onLogin}
341
- canLoop={canLoop}
342
- qrCodeScanOptions={props.config.qrCodeScanOptions}
343
- />
344
- </Tabs.TabPane>
345
- )}
346
- </Tabs>
347
- </div>
348
- )}
349
- <div className="g2-social-login">
350
- <SocialLogin
351
- appId={props.appId}
352
- config={props.config}
353
- onLogin={onLogin}
354
- />
355
- </div>
356
- <ChangeLanguage langRange={langRange} onLangChange={props.onLangChange} />
357
- </div>
358
- )
359
- }
@@ -1,90 +0,0 @@
1
- import {
2
- getDefaultG2Config,
3
- IG2Config,
4
- IG2Events,
5
- IG2FCProps,
6
- IG2FCViewProps,
7
- } from '../Type'
8
- import { CommonMessage, SocialConnectionProvider } from 'authing-js-sdk'
9
- import { QrCodeAuthenticationClient } from 'authing-js-sdk/build/main/lib/authentication/QrCodeAuthenticationClient'
10
- import { PasswordLoginMethods } from '../AuthingGuard/api'
11
- import {
12
- PasswordLoginParams,
13
- LDAPLoginParams,
14
- ADLoginParams,
15
- PhoneCodeLoginParams,
16
- AuthenticationClient,
17
- LoginMethods,
18
- User,
19
- } from '..'
20
-
21
- export interface LoginConfig extends IG2Config {
22
- autoRegister: boolean
23
- disableResetPwd: boolean
24
- disableRegister: boolean
25
- defaultLoginMethod: LoginMethods
26
- loginMethods: LoginMethods[]
27
- passwordLoginMethods: PasswordLoginMethods[]
28
- socialConnections?: SocialConnectionProvider[]
29
- socialConnectionsBtnShape?: 'default' | 'rectangle' | 'round'
30
- enterpriseConnections?: string[]
31
- qrCodeScanOptions?: Parameters<QrCodeAuthenticationClient['startScanning']>[1]
32
- publicKey?: string
33
- }
34
-
35
- const defaultConfig: LoginConfig = {
36
- ...getDefaultG2Config(),
37
- autoRegister: false,
38
- disableResetPwd: false,
39
- disableRegister: false,
40
- defaultLoginMethod: LoginMethods.Password,
41
- loginMethods: [LoginMethods.Password, LoginMethods.PhoneCode],
42
- socialConnectionsBtnShape: 'default',
43
- passwordLoginMethods: [
44
- 'email-password',
45
- 'username-password',
46
- 'phone-password',
47
- ],
48
- }
49
-
50
- export interface LoginEvents extends IG2Events {
51
- onLogin?: (user: User, authClient: AuthenticationClient) => void
52
- onLoginError?: (user: User, authClient: AuthenticationClient) => void
53
- onLoginTabChange?: (activeTab: LoginMethods) => void
54
- onBeforeLogin?: (
55
- loginInfo:
56
- | PasswordLoginParams
57
- | LDAPLoginParams
58
- | ADLoginParams
59
- | PhoneCodeLoginParams,
60
- authClient: AuthenticationClient
61
- ) => boolean | Promise<boolean>
62
- // pwd 开头的是重置密码的场景用的
63
- onPwdEmailSend?: (authClient: AuthenticationClient) => void
64
- onPwdEmailSendError?: (
65
- error: CommonMessage,
66
- authClient: AuthenticationClient
67
- ) => void
68
- onPwdPhoneSend?: (authClient: AuthenticationClient) => void
69
- onPwdPhoneSendError?: (
70
- error: CommonMessage,
71
- authClient: AuthenticationClient
72
- ) => void
73
- onPwdReset?: (authClient: AuthenticationClient) => void
74
- onPwdResetError?: (
75
- error: CommonMessage,
76
- authClient: AuthenticationClient
77
- ) => void
78
- }
79
-
80
- export interface GuardLoginProps extends IG2FCProps, LoginEvents {
81
- config?: Partial<LoginConfig>
82
- }
83
- export interface GuardLoginViewProps extends GuardLoginProps, IG2FCViewProps {
84
- config: LoginConfig
85
- }
86
-
87
- export const getDefaultLoginConfig = (): LoginConfig => ({
88
- ...getDefaultG2Config(),
89
- ...defaultConfig,
90
- })