diff --git a/client/src/components/Logins/EmailLogin.tsx b/client/src/components/Logins/EmailLogin.tsx index b1b10a31..a284a1a1 100644 --- a/client/src/components/Logins/EmailLogin.tsx +++ b/client/src/components/Logins/EmailLogin.tsx @@ -31,14 +31,19 @@ const EmailLoginModal: React.FC = ({ onClose, onLogin }) = const handleLoginClick = async () => { try { // 백엔드에 로그인 요청 - const response = await axios.post("http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080/login", { + const response = await axios.post("http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080/members/login", { email, password, }); if (response.status === 200) { - // 성공적으로 로그인된 경우, 토큰을 로컬 스토리지에 저장 - const authToken = response.data.authorization; - localStorage.setItem('authToken', authToken); + const authToken = response.headers['authorization']; + const accessToken = response.headers['accessToken']; + const refreshToken = response.headers['refreshToken']; + + // 토큰들을 로컬 스토리지에 저장 + if(authToken) localStorage.setItem('authToken', authToken); + if(accessToken) localStorage.setItem('accessToken', accessToken); + if(refreshToken) localStorage.setItem('refreshToken', refreshToken); onLogin(); onClose(); } else { diff --git a/client/src/components/Logins/OAuthLogin.tsx b/client/src/components/Logins/OAuthLogin.tsx index 6ccd6ea9..9ad7da78 100644 --- a/client/src/components/Logins/OAuthLogin.tsx +++ b/client/src/components/Logins/OAuthLogin.tsx @@ -19,6 +19,14 @@ const OAuthLoginModal: React.FC = ({ onClose, onEmailLoginClick try { const response = await axios.post('/oauth2/authorization/google'); if (response.status === 200) { + const authToken = response.headers['authorization']; + const accessToken = response.headers['accessToken']; + const refreshToken = response.headers['refreshToken']; + + // 토큰들을 로컬 스토리지에 저장 + if(authToken) localStorage.setItem('authToken', authToken); + if(accessToken) localStorage.setItem('accessToken', accessToken); + if(refreshToken) localStorage.setItem('refreshToken', refreshToken); console.log("Successfully logged in with Google!"); onClose(); } else { @@ -34,6 +42,14 @@ const OAuthLoginModal: React.FC = ({ onClose, onEmailLoginClick try { const response = await axios.post('/oauth2/authorization/kakao'); if (response.status === 200) { + const authToken = response.headers['authorization']; + const accessToken = response.headers['accessToken']; + const refreshToken = response.headers['refreshToken']; + + // 토큰들을 로컬 스토리지에 저장 + if(authToken) localStorage.setItem('authToken', authToken); + if(accessToken) localStorage.setItem('accessToken', accessToken); + if(refreshToken) localStorage.setItem('refreshToken', refreshToken); console.log("Successfully logged in with Kakao!"); onClose(); } else { diff --git a/client/src/components/Signups/Password.tsx b/client/src/components/Signups/Password.tsx index 14a6b07f..af485a29 100644 --- a/client/src/components/Signups/Password.tsx +++ b/client/src/components/Signups/Password.tsx @@ -60,7 +60,7 @@ const PasswordSettingModal: React.FC = ({ onClose, on confirmPassword, }); - if (response.status === 200) { + if (response.status === 201) { console.log('Data sent successfully'); onClose(); onNext();