diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index f726411..e3861e4 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -16,7 +16,7 @@ const Login: FC = ({ login, setLogin }) => { }, []); useEffect(() => { - const cookie = getCookie("at"); + const cookie = getCookie("login"); const isLogin = localStorage.getItem("isLogin"); if (isLogin === "true" && cookie) navigate("/main"); else setLogin(true); diff --git a/src/pages/Redirect.tsx b/src/pages/Redirect.tsx index 5b7eab2..a68ac72 100644 --- a/src/pages/Redirect.tsx +++ b/src/pages/Redirect.tsx @@ -1,4 +1,4 @@ -import { useEffect } from "react"; +import { useEffect, useLayoutEffect } from "react"; import { useNavigate } from "react-router"; import Loading from "@utils/Loading"; import { getCookie } from "@utils/getCookie"; @@ -6,12 +6,15 @@ import { getCookie } from "@utils/getCookie"; const Redirect = () => { const navigate = useNavigate(); - useEffect(() => { - const cookie = getCookie("at"); + useLayoutEffect(() => { + const cookie = getCookie("login"); if (!cookie) { alert("로그인 정보가 유효하지 않습니다. 다시 로그인 해주세요."); navigate("/"); } + }, []); + + useEffect(() => { localStorage.setItem("isLogin", "true"); navigate("/main"); }, []); diff --git a/src/utils/MainRouter.tsx b/src/utils/MainRouter.tsx index 8db1272..c9781f9 100644 --- a/src/utils/MainRouter.tsx +++ b/src/utils/MainRouter.tsx @@ -15,7 +15,7 @@ const MainRouter: FC = ({ setLogin }) => { const navigate = useNavigate(); useLayoutEffect(() => { - const cookie = getCookie("at"); + const cookie = getCookie("login"); const isLogin = localStorage.getItem("isLogin"); if (!(isLogin === "true" && cookie)) { alert("로그인 정보가 유효하지 않습니다. 다시 로그인 해주세요."); @@ -23,7 +23,7 @@ const MainRouter: FC = ({ setLogin }) => { }, []); useEffect(() => { - const cookie = getCookie("at"); + const cookie = getCookie("login"); const isLogin = localStorage.getItem("isLogin"); if (!(isLogin === "true" && cookie)) { setLogin(true);