From 5dd92089830abd448b476398d4c81b7fadef7997 Mon Sep 17 00:00:00 2001 From: thejsw Date: Wed, 7 Sep 2022 21:11:22 +0900 Subject: [PATCH] =?UTF-8?q?[#32]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EC=97=90=20=EB=94=B0=EB=A5=B8=20console=20=EC=B6=9C?= =?UTF-8?q?=EB=A0=A5=20>>=20=EC=95=88=EB=90=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/components/Signin.jsx | 10 +++------- front/src/remotes/index.jsx | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/front/src/components/Signin.jsx b/front/src/components/Signin.jsx index 8d816f7..3c54ab1 100644 --- a/front/src/components/Signin.jsx +++ b/front/src/components/Signin.jsx @@ -16,7 +16,6 @@ const Signin = () => { } }, [isLoggedIn]); - return (
@@ -37,15 +36,14 @@ const Signin = () => { e.preventDefault(); postUsersLogin({ email, password }).then((res) => { - if (res.user) { + if (res.data.user) { setIsLoggedIn(true); - localStorage.setItem('token', res.user.token); + localStorage.setItem('token', res.data.user.token); } }); }} >
- { diff --git a/front/src/remotes/index.jsx b/front/src/remotes/index.jsx index cc692dc..b17514e 100644 --- a/front/src/remotes/index.jsx +++ b/front/src/remotes/index.jsx @@ -1,6 +1,7 @@ // @ts-check - +import React, { useState, useEffect } from 'react'; import axios from 'axios'; +import Signin from '../components/Signin'; const conduitAxios = axios.create({ baseURL: @@ -68,9 +69,25 @@ const conduitAxios = axios.create({ // ㅡㅡㅡㅡㅡ User ㅡㅡㅡㅡㅡ /** * @param {{ email: string; password: string;}} user - * @returns {Promise<{ user: User }>} + * @returns {Promise<{ data: { user: User }}>} */ const postUsersLogin = (user) => conduitAxios.post(`/users/login`); +postUsersLogin() + .then((res) => { + console.log(res); + console.log(`res.data.email :: ${res.data.user.email}`); + if (res.data.user.email === undefined) { + console.log(`입력하신 id가 일치하지 않습니다`); + } else if (res.data.user.email === null) { + console.log(`입력하신 비밀번호가 일치하지 않습니다`); + } else if (res.data.user.email === props.email) { + console.log(`로그인 성공`); + } + document.location.href = '/'; + }) + .catch((e) => { + console.log(e); + }); /** * @param {{username: string; email: string; password: string;}} user