From 512a4a8b22197c730f79d8a67a976fcbd49e2cca Mon Sep 17 00:00:00 2001 From: hwna00 Date: Wed, 20 Sep 2023 20:40:04 +0900 Subject: [PATCH] =?UTF-8?q?Feat(user):=20fb=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=20=ED=95=A8=EC=88=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 로직은 firebase.js 파일 내에서 처리하도록 수정 ref: #67 --- packages/apps/user/firebase.js | 15 ++++++++++++--- packages/apps/user/src/views/Auth/LogIn/LogIn.js | 13 +++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/apps/user/firebase.js b/packages/apps/user/firebase.js index ebf8da9c..f44048e9 100644 --- a/packages/apps/user/firebase.js +++ b/packages/apps/user/firebase.js @@ -49,12 +49,21 @@ const fbSignUp = data => { }); }; -const logIn = (email, password) => { - return signInWithEmailAndPassword(auth, email, password); +const fbLogIn = data => { + const { email, data } = data; + + //TODO: DB에 해당 email과 같은 메일이 존재하는지 확인. 존재한다면 해당 아이디가 이미 존재한다는 경고메시지 전송 + + signInWithEmailAndPassword(auth, email, password) + .then(userCredential => { + const { email } = userCredential.user; + //TODO: email을 가지는 user 정보를 DB에서 가져온다. + }) + .catch(); }; const googleLogin = () => { return signInWithPopup(auth, provider); }; -export { auth, fbSignUp, logIn, googleLogin, provider, storage }; +export { auth, fbSignUp, fbLogIn, googleLogin, provider, storage }; diff --git a/packages/apps/user/src/views/Auth/LogIn/LogIn.js b/packages/apps/user/src/views/Auth/LogIn/LogIn.js index 37dbcf72..245cfe63 100644 --- a/packages/apps/user/src/views/Auth/LogIn/LogIn.js +++ b/packages/apps/user/src/views/Auth/LogIn/LogIn.js @@ -21,7 +21,7 @@ import { Icon, } from '@chakra-ui/react'; -import { logIn, googleLogin, auth, provider } from '../../../../firebase'; +import { googleLogin, auth, provider, fbLogIn } from '../../../../firebase'; import NaverLoginButton from '../../../components/NaverLoginButton/NaverLoginButton'; function LogIn() { @@ -29,6 +29,7 @@ function LogIn() { const handleShowClick = useCallback(() => { setShowPassword(!showPassword); }, [showPassword]); + const navigate = useNavigate(); const { register, @@ -37,15 +38,7 @@ function LogIn() { } = useForm(); const onSubmit = function (data) { - const { email, password } = data; - logIn(email, password) - .then(() => { - navigate('/'); - }) - .catch(error => { - console.log(error); - navigate('/error'); - }); + fbLogIn(data); }; const googleClick = useCallback(() => {