diff --git a/src/pages/Landing/Landing.tsx b/src/pages/Landing/Landing.tsx index 819589d1..36a4ab7d 100644 --- a/src/pages/Landing/Landing.tsx +++ b/src/pages/Landing/Landing.tsx @@ -14,18 +14,33 @@ import StartWithTemplates from "./StartWithTemplates"; import WhatTheFeatures from "./WhatTheFeatures"; import FullScreenDialog from "./headerMobileLanding"; import Collaboration from "./Collaboration"; -import { setAuthToken } from "@frontend/kitui"; +import { clearAuthToken, setAuthToken } from "@frontend/kitui"; +import { useParams } from 'react-router-dom'; +import { clearUserData, setUserId, useUserStore } from "@root/user"; +import { cleanAuthTicketData } from "@root/ticket"; export default function Landing() { const theme = useTheme(); const isTablet = useMediaQuery(theme.breakpoints.down(1000)); - useEffect(() => { - const currentUrl = window.location.search.split("=")[1]; - if (currentUrl !== "") { - setAuthToken(currentUrl); - history.pushState(null, document.title, "/"); + const data = useParams(); + const { user } = useUserStore() + + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + const userId = urlParams.get("userId"); + const action = urlParams.get("action"); + + console.log(userId, action) + if (userId && action) { + history.pushState(null, document.title, "/"); + if (user?._id) { + cleanAuthTicketData(); + clearAuthToken(); + clearUserData(); } - }, []); + setAuthToken(action); + setUserId(userId) + } return ( <>