Skip to content

Commit

Permalink
Feat(user): fb 로그인 함수 수정
Browse files Browse the repository at this point in the history
- 로직은 firebase.js 파일 내에서 처리하도록 수정

ref: #67
  • Loading branch information
hwna00 committed Sep 25, 2023
1 parent ea38709 commit 512a4a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 12 additions & 3 deletions packages/apps/user/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
13 changes: 3 additions & 10 deletions packages/apps/user/src/views/Auth/LogIn/LogIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ 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() {
const [showPassword, setShowPassword] = useState(false);
const handleShowClick = useCallback(() => {
setShowPassword(!showPassword);
}, [showPassword]);

const navigate = useNavigate();
const {
register,
Expand All @@ -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(() => {
Expand Down

0 comments on commit 512a4a8

Please sign in to comment.