diff --git a/packages/global/support/user/type.d.ts b/packages/global/support/user/type.d.ts index c3700b8e81e..1cb768dd33d 100644 --- a/packages/global/support/user/type.d.ts +++ b/packages/global/support/user/type.d.ts @@ -18,6 +18,9 @@ export type UserModelSchema = { key: string; baseUrl: string; }; + fastgpt_sem?: { + keyword: string; + }; }; export type UserType = { diff --git a/packages/service/support/user/schema.ts b/packages/service/support/user/schema.ts index 7ba5303d03b..c3dcc6852ad 100644 --- a/packages/service/support/user/schema.ts +++ b/packages/service/support/user/schema.ts @@ -70,6 +70,9 @@ const UserSchema = new Schema({ }, lastLoginTmbId: { type: Schema.Types.ObjectId + }, + fastgpt_sem: { + type: Object } }); diff --git a/projects/app/src/pages/login/components/LoginForm/components/FormLayout.tsx b/projects/app/src/pages/login/components/LoginForm/components/FormLayout.tsx index ea83bc4b2c6..44e100f2333 100644 --- a/projects/app/src/pages/login/components/LoginForm/components/FormLayout.tsx +++ b/projects/app/src/pages/login/components/LoginForm/components/FormLayout.tsx @@ -71,7 +71,8 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => { : []) ]; - const show_oauth = !!(feConfigs?.sso || oAuthList.length > 0); + const show_oauth = + !sessionStorage.getItem('bd_vid') && !!(feConfigs?.sso || oAuthList.length > 0); return ( diff --git a/projects/app/src/pages/login/components/RegisterForm.tsx b/projects/app/src/pages/login/components/RegisterForm.tsx index 044cb1bdf13..7030c533b2c 100644 --- a/projects/app/src/pages/login/components/RegisterForm.tsx +++ b/projects/app/src/pages/login/components/RegisterForm.tsx @@ -45,13 +45,24 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => { const { runAsync: onclickRegister, loading: requesting } = useRequest2( async ({ username, password, code }: RegisterType) => { + const fastgpt_sem = (() => { + try { + return sessionStorage.getItem('fastgpt_sem') + ? JSON.parse(sessionStorage.getItem('fastgpt_sem')!) + : undefined; + } catch { + return undefined; + } + })(); + loginSuccess( await postRegister({ username, code, password, inviterId: localStorage.getItem('inviterId') || undefined, - bd_vid: localStorage.getItem('bd_vid') || undefined + bd_vid: sessionStorage.getItem('bd_vid') || undefined, + fastgpt_sem: fastgpt_sem }) ); diff --git a/projects/app/src/pages/login/index.tsx b/projects/app/src/pages/login/index.tsx index b4916cc396c..546d63e1894 100644 --- a/projects/app/src/pages/login/index.tsx +++ b/projects/app/src/pages/login/index.tsx @@ -86,6 +86,11 @@ const Login = ({ ChineseRedirectUrl }: { ChineseRedirectUrl: string }) => { /* default login type */ useEffect(() => { + const bd_vid = sessionStorage.getItem('bd_vid'); + if (bd_vid) { + setPageType(LoginPageTypeEnum.passwordLogin); + return; + } setPageType( feConfigs?.oauth?.wechat ? LoginPageTypeEnum.wechat : LoginPageTypeEnum.passwordLogin ); diff --git a/projects/app/src/web/context/useInitApp.ts b/projects/app/src/web/context/useInitApp.ts index 228c4d08423..f175c21157f 100644 --- a/projects/app/src/web/context/useInitApp.ts +++ b/projects/app/src/web/context/useInitApp.ts @@ -8,7 +8,7 @@ import { TrackEventName } from '../common/system/constants'; export const useInitApp = () => { const router = useRouter(); - const { hiId, bd_vid } = router.query as { hiId?: string; bd_vid?: string }; + const { hiId, bd_vid, k } = router.query as { hiId?: string; bd_vid?: string; k?: string }; const { loadGitStar, setInitd, feConfigs } = useSystemStore(); const [scripts, setScripts] = useState([]); const [title, setTitle] = useState(process.env.SYSTEM_NAME || 'AI'); @@ -59,8 +59,9 @@ export const useInitApp = () => { useEffect(() => { hiId && localStorage.setItem('inviterId', hiId); - bd_vid && localStorage.setItem('bd_vid', bd_vid); - }, [bd_vid, hiId]); + bd_vid && sessionStorage.setItem('bd_vid', bd_vid); + k && sessionStorage.setItem('fastgpt_sem', JSON.stringify({ keyword: k })); + }, [bd_vid, hiId, k]); return { feConfigs, diff --git a/projects/app/src/web/support/user/api.ts b/projects/app/src/web/support/user/api.ts index 2abeb127d03..955e47c077c 100644 --- a/projects/app/src/web/support/user/api.ts +++ b/projects/app/src/web/support/user/api.ts @@ -31,19 +31,24 @@ export const postRegister = ({ password, code, inviterId, - bd_vid + bd_vid, + fastgpt_sem }: { username: string; code: string; password: string; inviterId?: string; bd_vid?: string; + fastgpt_sem?: { + keyword: string; + }; }) => POST(`/proApi/support/user/account/register/emailAndPhone`, { username, code, inviterId, bd_vid, + fastgpt_sem, password: hashStr(password) });