From 7745df191306903dbb0f8f492684c876c3b2a6aa Mon Sep 17 00:00:00 2001 From: ydj515 Date: Thu, 10 Oct 2024 11:11:03 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20token=20check=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=A0=84=EC=B2=B4=20=EB=9D=BC=EC=9A=B0=ED=8A=B8=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20=EB=B0=8F=20=EB=B6=88=ED=95=84=EC=9A=94=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 27 +++++++++++---------------- src/pages/Login.js | 2 +- src/routes/CheckLocalStorage.js | 9 +++++---- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/App.js b/src/App.js index 3f444e7..f3a286a 100644 --- a/src/App.js +++ b/src/App.js @@ -10,22 +10,17 @@ import CheckLocalStorage from "./routes/CheckLocalStorage"; const App = () => { return ( - - - - - } - > - } /> - } /> - } /> - } /> - } /> - - + + + }> + } /> + } /> + } /> + } /> + } /> + + + ); }; diff --git a/src/pages/Login.js b/src/pages/Login.js index dcbaf5a..8442a73 100644 --- a/src/pages/Login.js +++ b/src/pages/Login.js @@ -31,7 +31,7 @@ function Login(props) { } const { accessToken } = response.data.data; - setTokenWithExpiry("accessToken", accessToken, 24 * 60 * 60 * 1000); + setTokenWithExpiry("accessToken", accessToken, 5 * 60 * 60 * 1000); Cookies.set("userId", response.data.data.userId, { expires: 1 }); alert("로그인 성공"); window.location.href = "/"; diff --git a/src/routes/CheckLocalStorage.js b/src/routes/CheckLocalStorage.js index 422fe17..094076e 100644 --- a/src/routes/CheckLocalStorage.js +++ b/src/routes/CheckLocalStorage.js @@ -1,12 +1,13 @@ -import { Navigate } from "react-router-dom"; +// import { Navigate } from "react-router-dom"; import { getTokenWithExpiry } from "../utils/auth"; const CheckLocalStorage = ({ children }) => { const token = getTokenWithExpiry("accessToken"); - // if (!token) { - // return ; - // } + if (!token) { + console.log("expired"); + // return ; + } return children; };