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 (