авторизация юзера при попадании с лендинга
This commit is contained in:
parent
6c4b929c68
commit
185a9dc6fb
@ -14,18 +14,33 @@ import StartWithTemplates from "./StartWithTemplates";
|
|||||||
import WhatTheFeatures from "./WhatTheFeatures";
|
import WhatTheFeatures from "./WhatTheFeatures";
|
||||||
import FullScreenDialog from "./headerMobileLanding";
|
import FullScreenDialog from "./headerMobileLanding";
|
||||||
import Collaboration from "./Collaboration";
|
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() {
|
export default function Landing() {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
||||||
useEffect(() => {
|
const data = useParams();
|
||||||
const currentUrl = window.location.search.split("=")[1];
|
const { user } = useUserStore()
|
||||||
if (currentUrl !== "") {
|
|
||||||
setAuthToken(currentUrl);
|
const queryString = window.location.search;
|
||||||
history.pushState(null, document.title, "/");
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user