From 17bfe8a2a65d53def3b4ab2e5517aa15033a91d0 Mon Sep 17 00:00:00 2001 From: jeasong Date: Thu, 6 May 2021 14:16:15 +0900 Subject: [PATCH] client token hotfix --- src/App.js | 28 +++++++++++++++++++++++----- src/WaitingPages/Waiting.js | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/App.js b/src/App.js index 8cd0cdc..020c736 100644 --- a/src/App.js +++ b/src/App.js @@ -29,11 +29,21 @@ export default function App() { const loginCheck = (isLogIn) => { if (!isLogIn) { history.push('/'); + }else if(isLogIn){ + history.push('/Waiting'); } }; const hendleLogout = () => { setIsLogIn(false); setAccessToken({ accessToken: null }); + axios + .get( + 'http://localhost:4000/login', + { + headers: { 'Content-Type': 'application/json' }, + withCredentials: true, + } + ).then((res) => {}) }; const accessTokenRequest = (accessToken) => { @@ -109,11 +119,19 @@ export default function App() { useEffect(() => { console.log('엑세스 토큰', accessToken.accessToken); - if (accessToken.accessToken !== null) { - setIsLogIn(true); - } - console.log('로그인상태', isLogIn); - }, [accessToken]); + // if (accessToken.accessToken !== null) { + // setIsLogIn(true); + // } + // console.log('로그인상태', isLogIn); + //엑세스 토큰이 없을때 + if(accessToken.accessToken===null){ + setIsLogIn(true) + loginCheck(isLogIn) + refreshTokenRequest() + console.log('로그인상태',isLogIn) + } + console.log('로그인상태',isLogIn) + },); const getAccessToken = async (authorizationCode) => { // ! 구글 로그인 diff --git a/src/WaitingPages/Waiting.js b/src/WaitingPages/Waiting.js index 010f6c2..f5b9132 100644 --- a/src/WaitingPages/Waiting.js +++ b/src/WaitingPages/Waiting.js @@ -50,7 +50,7 @@ export default function Waiting({ }, [locationKeys]); useEffect(() => { loginCheck(isLogIn); - }); + },[]); return (