Skip to content

Commit

Permalink
feat: issue new token for already login with httpOnly=false #30
Browse files Browse the repository at this point in the history
  • Loading branch information
luckylooky2 committed Sep 25, 2023
1 parent d8b6c1f commit 6c341e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Login: FC<Props> = ({ 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);
Expand Down
9 changes: 6 additions & 3 deletions src/pages/Redirect.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { useEffect } from "react";
import { useEffect, useLayoutEffect } from "react";
import { useNavigate } from "react-router";
import Loading from "@utils/Loading";
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");
}, []);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/MainRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ const MainRouter: FC<Props> = ({ setLogin }) => {
const navigate = useNavigate();

useLayoutEffect(() => {
const cookie = getCookie("at");
const cookie = getCookie("login");
const isLogin = localStorage.getItem("isLogin");
if (!(isLogin === "true" && cookie)) {
alert("로그인 정보가 유효하지 않습니다. 다시 로그인 해주세요.");
}
}, []);

useEffect(() => {
const cookie = getCookie("at");
const cookie = getCookie("login");
const isLogin = localStorage.getItem("isLogin");
if (!(isLogin === "true" && cookie)) {
setLogin(true);
Expand Down

0 comments on commit 6c341e5

Please sign in to comment.