diff --git a/packages/console/package.json b/packages/console/package.json index b0cd806fe..0de8c85de 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -24,7 +24,7 @@ "@logto/language-kit": "workspace:*", "@logto/phrases": "workspace:*", "@logto/phrases-ui": "workspace:*", - "@logto/react": "1.0.0", + "@logto/react": "1.1.0", "@logto/schemas": "workspace:*", "@mdx-js/react": "^1.6.22", "@microsoft/applicationinsights-react-js": "^3.4.1", diff --git a/packages/console/src/consts/index.ts b/packages/console/src/consts/index.ts index b6d3dc70e..ed48a9443 100644 --- a/packages/console/src/consts/index.ts +++ b/packages/console/src/consts/index.ts @@ -10,3 +10,7 @@ export const appearanceModeStorageKey = 'logto:admin_console:appearance_mode'; export const profileSocialLinkingKeyPrefix = 'logto:admin_console:linking_social_connector'; export const requestTimeout = 20_000; export const defaultPageSize = 20; + +export enum searchKeys { + signUp = 'sign_up', +} diff --git a/packages/console/src/containers/AppContent/index.tsx b/packages/console/src/containers/AppContent/index.tsx index 0799a70f8..56ed811ff 100644 --- a/packages/console/src/containers/AppContent/index.tsx +++ b/packages/console/src/containers/AppContent/index.tsx @@ -1,12 +1,13 @@ import { LogtoClientError, LogtoError, useLogto } from '@logto/react'; -import { conditional } from '@silverhand/essentials'; +import { conditional, yes } from '@silverhand/essentials'; import { useEffect, useRef } from 'react'; import { useTranslation } from 'react-i18next'; -import { Outlet, useHref, useLocation, useNavigate } from 'react-router-dom'; +import { Outlet, useHref, useLocation, useNavigate, useSearchParams } from 'react-router-dom'; import AppError from '@/components/AppError'; import AppLoading from '@/components/AppLoading'; import SessionExpired from '@/components/SessionExpired'; +import { searchKeys } from '@/consts'; import { isCloud } from '@/consts/cloud'; import useConfigs from '@/hooks/use-configs'; import useScroll from '@/hooks/use-scroll'; @@ -29,6 +30,7 @@ const AppContent = () => { const location = useLocation(); const navigate = useNavigate(); + const [searchParameters] = useSearchParams(); const { firstItem } = useSidebarMenuItems(); const scrollableContent = useRef(null); const { scrollTop } = useScroll(scrollableContent.current); @@ -36,9 +38,14 @@ const AppContent = () => { useEffect(() => { if (!isAuthenticated && !isLogtoLoading) { - void signIn(new URL(href, window.location.origin).toString()); + const signUpFirst = searchParameters.get(searchKeys.signUp); + + void signIn( + new URL(href, window.location.origin).toString(), + conditional(yes(signUpFirst) && 'signUp') + ); } - }, [href, isAuthenticated, isLogtoLoading, signIn]); + }, [href, isAuthenticated, isLogtoLoading, searchParameters, signIn]); useEffect(() => { // Navigate to the first menu item after configs are loaded. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f31c67515..3058298db 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -187,7 +187,7 @@ importers: '@logto/language-kit': workspace:* '@logto/phrases': workspace:* '@logto/phrases-ui': workspace:* - '@logto/react': 1.0.0 + '@logto/react': 1.1.0 '@logto/schemas': workspace:* '@mdx-js/react': ^1.6.22 '@microsoft/applicationinsights-react-js': ^3.4.1 @@ -267,7 +267,7 @@ importers: '@logto/language-kit': link:../toolkit/language-kit '@logto/phrases': link:../phrases '@logto/phrases-ui': link:../phrases-ui - '@logto/react': 1.0.0_react@18.2.0 + '@logto/react': 1.1.0_react@18.2.0 '@logto/schemas': link:../schemas '@mdx-js/react': 1.6.22_react@18.2.0 '@microsoft/applicationinsights-react-js': 3.4.1_ru3n4sc2jwbij7oomq3xpksl5a @@ -2485,6 +2485,14 @@ packages: js-base64: 3.7.4 dev: true + /@logto/browser/1.1.0: + resolution: {integrity: sha512-0NpRVM+D1d4bCwpQb0OcgE6cKKwLevqdMCBjVLlosi527ydMa25X3cEuvRw+bojxSF3QfS/Ig9GktS7xvUAnCg==} + dependencies: + '@logto/client': 1.1.0 + '@silverhand/essentials': 1.3.0 + js-base64: 3.7.4 + dev: true + /@logto/client/1.0.0: resolution: {integrity: sha512-80tqgNdZRT9hmxznpkpb1UjOdtBO5FMyFU2GYvym5j6zCTQxi3dGXlgNRzOUDX2sHM1PqkUvsVM2IzgMGGNjvg==} dependencies: @@ -2496,6 +2504,17 @@ packages: lodash.once: 4.1.1 dev: true + /@logto/client/1.1.0: + resolution: {integrity: sha512-HdUuH6vwbKzhLoa7JgWu85CMTU8a7lux9Uadv5yitMaJMEsYERUU0SntQC8jZ7K5/Ktc8r/3kbfo0MKyFNffMA==} + dependencies: + '@logto/js': 1.1.0 + '@silverhand/essentials': 1.3.0 + camelcase-keys: 7.0.2 + jose: 4.11.1 + lodash.get: 4.4.2 + lodash.once: 4.1.1 + dev: true + /@logto/js/1.0.0: resolution: {integrity: sha512-brhyDIIDzIpsvcvQZHWjiYknKO//py3YnxfdWx9P1OkcyF1iIAiYv0o25/XXzfsb3XS0TkP1FdvLhLp/LDLz5g==} dependencies: @@ -2505,6 +2524,15 @@ packages: lodash.get: 4.4.2 dev: true + /@logto/js/1.1.0: + resolution: {integrity: sha512-YW8ou7DifY0T9Pfli3sZG9sdm5UbINcHEi9pkj6pGxVUX5lBWRxT+ZWGgOsRl4KtrPXzg9ivAAJHzyPRwZAf7g==} + dependencies: + '@silverhand/essentials': 1.3.0 + camelcase-keys: 7.0.2 + jose: 4.11.1 + lodash.get: 4.4.2 + dev: true + /@logto/node/1.0.0: resolution: {integrity: sha512-I/sC+JKbmJiufBXmqWFYpp+bpYHb15hoiieexzIDbsaoosQjHjSdAwqQjz6w60e2yQuWvxctP7Cc44L0BVgaSQ==} dependencies: @@ -2526,6 +2554,16 @@ packages: react: 18.2.0 dev: true + /@logto/react/1.1.0_react@18.2.0: + resolution: {integrity: sha512-uz7kevuDVd9CMXVhQ3Mt7eVcV0a5Ghcmn6YabS6Sjv9kJCmpRHXGJrVHP4mah+vSEUGirGtoKLVNE8kyPdDVIA==} + peerDependencies: + react: '>=16.8.0 || ^18.0.0' + dependencies: + '@logto/browser': 1.1.0 + '@silverhand/essentials': 1.3.0 + react: 18.2.0 + dev: true + /@manypkg/find-root/1.1.0: resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} dependencies: