From 84e8289f5401f91f929242cd7f8e04c737bc373c Mon Sep 17 00:00:00 2001 From: jmj Date: Fri, 14 Jun 2024 19:57:18 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=8B=9C?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=EC=9D=B8,=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=20=EC=A0=91?= =?UTF-8?q?=EA=B7=BC=20=EB=B6=88=EA=B0=80=EB=8A=A5=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/SignIn.tsx | 18 +----------------- src/pages/SignUp.tsx | 9 +++++++++ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/pages/SignIn.tsx b/src/pages/SignIn.tsx index 7d18af424..c29c773c8 100644 --- a/src/pages/SignIn.tsx +++ b/src/pages/SignIn.tsx @@ -11,11 +11,9 @@ import { getAccessToken, setAccessToken, setRefreshToken, - clearTokens, getRefreshToken, } from '../Utils/TokenManager'; import { refreshAccessToken } from '../api/Auth.api'; -import instance from '../api/Axios'; const SignIn: React.FC = () => { const [email, setEmail] = useState(''); @@ -45,21 +43,7 @@ const SignIn: React.FC = () => { } if (accessToken) { - try { - // 사용자 정보 가져오기 - const response = await instance.get('/api/user-info', { - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }); - if (response.status === 200) { - console.log('User is logged in:', response.data); - navigate('/'); - } - } catch (error) { - console.error('Auto login failed:', error); - clearTokens(); - } + navigate('/'); } }; autoLogin(); diff --git a/src/pages/SignUp.tsx b/src/pages/SignUp.tsx index 9cfdf1961..3eadd5f8c 100644 --- a/src/pages/SignUp.tsx +++ b/src/pages/SignUp.tsx @@ -13,6 +13,7 @@ import PasswordInputField from '../components/Sign/PasswordInputField'; import SocialSignIn from '../components/Sign/SocialSignIn'; import { PostSignUp } from '../api/Validator.api'; import { useNavigate } from 'react-router'; +import { getAccessToken } from 'Utils/TokenManager'; const SignUp: React.FC = () => { const [email, setEmail] = useState(''); @@ -31,6 +32,14 @@ const SignUp: React.FC = () => { const navigate = useNavigate(); + useEffect(() => { + const accessToken = getAccessToken(); + + if (accessToken) { + navigate('/'); + } + }, [navigate]); + // 입력 필드 검증 함수 const validateField = (name: string, value: string) => { let error = '';