From e7068233d0a0addf807cfc60384fab1e5d7bdb43 Mon Sep 17 00:00:00 2001 From: mniYUNSU Date: Wed, 1 Sep 2021 10:57:30 +0900 Subject: [PATCH] =?UTF-8?q?[CLIENT]=20Modal.js=20:=20=EC=B9=B4=EC=B9=B4?= =?UTF-8?q?=EC=98=A4=20=EC=86=8C=EC=85=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/comp/Modal.js | 43 ++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/client/src/comp/Modal.js b/client/src/comp/Modal.js index 7ceb558..380f3f2 100644 --- a/client/src/comp/Modal.js +++ b/client/src/comp/Modal.js @@ -391,13 +391,40 @@ function Modal({ setOnModal, setisLogin, setUserInfo, setAccToken, accToken }) { const selectMenuHandler = (index) => { setCurrentTab(index); }; - // const kakaoLoginHandler = () => { - // const code = new URL(window.location.href).searchParams.get("code"); - // console.log(code); - // }; - // const kakaoLoginHandler = async () => { - // await loginWithKakao(); - // }; + + const kakaoLoginHandler = async (res) => { + await loginWithKakao(res); + }; + + const loginWithKakao = async (res) => { + console.log(res); + const code = await new URL(window.location.href).searchParams.get("code"); + const email = await JSON.stringify(res.profile.kakao_account.email); + const username = await JSON.stringify(res.profile.properties.nickname); + const userPic = await JSON.stringify(res.profile.properties.profile_image); + console.log(email, username, userPic); + const data = { + email: email.slice(1, -1), + username: username.slice(1, -1), + userPic: userPic.slice(1, -1), + password: "kakao1234!", + phone: "01077777777", + }; + console.log(data); + console.log(data.userPic); + // let signupResult = await axios.post(`${url}/user/signup`, { + // email: email, + // password: "kakao1234login", + // username: username, + // phone: "01088888888", + // userPic: userPic, + // }); + // console.log(signupResult.data.message); + // history.push("/"); + // setisLogin(true); + // setOnModal(false); + // alert("로그인 완료되었습니다."); + }; // const loginWithKakao = async () => { // const loginRes = await Kakao.Auth.login({ @@ -460,7 +487,7 @@ function Modal({ setOnModal, setisLogin, setUserInfo, setAccToken, accToken }) { console.log(res)} + onSuccess={(res) => kakaoLoginHandler(res)} onFailure={(res) => console.log(res)} getProfile={true} onLogout={console.info}