авторизация юзера при попадании с лендинга
This commit is contained in:
parent
6c4b929c68
commit
185a9dc6fb
@ -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 (
|
||||
<>
|
||||
|
Loading…
Reference in New Issue
Block a user