diff --git a/src/pages/Login/index.tsx b/src/pages/Login/index.tsx index 8d690d785..552d98eeb 100644 --- a/src/pages/Login/index.tsx +++ b/src/pages/Login/index.tsx @@ -25,30 +25,19 @@ export const LoginPage = () => { }, [searchParams]); const handleConfirm = async () => { - const registerData = authSessionStorage.get(); - if (registerData) { - if (email !== registerData.email) { - alert('존재하지 않는 이메일입니다.'); - } else if (password !== registerData.password) { - alert('존재하지 않는 비밀번호입니다.'); - } - } else { - alert('회원 정보를 찾을 수 없습니다.'); + try { + const response = await fetchInstance.post(`${BASE_URL}/api/members/login`, { + email: email, + password: password, + }); + const data = await response.data; + authSessionStorage.set({ token: data.token, email: email }); + const redirectUrl = queryParams.get('redirect') ?? `${window.location.origin}/`; + return window.location.replace(redirectUrl); + } catch (error) { + console.error('Failed sign in', error); + alert('로그인 중 오류가 발생했습니다.'); } - if (registerData && email === registerData.email && password === registerData.password) - try { - const response = await fetchInstance.post(`${BASE_URL}/api/members/login`, { - email: email, - password: password, - }); - const data = await response.data; - authSessionStorage.set({ token: data.token, email: data.email }); - const redirectUrl = queryParams.get('redirect') ?? `${window.location.origin}/`; - return window.location.replace(redirectUrl); - } catch (error) { - console.error('Failed sign in', error); - alert('로그인 중 오류가 발생했습니다.'); - } }; const handleKakaoLogin = async () => { try { diff --git a/src/pages/SignUp/index.tsx b/src/pages/SignUp/index.tsx index 8142dd70c..53143570a 100644 --- a/src/pages/SignUp/index.tsx +++ b/src/pages/SignUp/index.tsx @@ -26,7 +26,7 @@ export const SignUpPage = () => { }); const data = response.data; - authSessionStorage.set({ token: data.token, email: data.email, password: password }); + authSessionStorage.set({ token: data.token, email: email, password: password }); window.location.replace(`${window.location.origin}/`); } catch (error) { console.error('Failed sign up', error);