-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/login 로그인 페이지 ui 및 파이어베이스 auth 연동 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/login 로그인 페이지 ui 및 파이어베이스 auth 연동 #21
Conversation
tkyoun0421
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 🙇
env 부분 제가 말씀 드렸어야 했는데.. 놓친 부분을 잘 챙겨주셔서 감사합니다 ㅠㅠ 고생 많으셨어요
| if (error.code === "auth/account-exists-with-different-credential") { | ||
| const email = error.customData?.email; | ||
|
|
||
| if (email) { | ||
| const methods = await fetchSignInMethodsForEmail(auth, email); | ||
| console.warn("이미 가입된 로그인 방법:", methods); | ||
|
|
||
| if (methods.length > 0) { | ||
| if (methods.includes("google.com")) { | ||
| alert( | ||
| "이미 Google 계정으로 가입된 이메일입니다. Google 로그인을 이용해주세요." | ||
| ); | ||
| } else { | ||
| alert(`이미 가입된 로그인 방법: ${methods.join(", ")}`); | ||
| } | ||
| } else { | ||
| alert( | ||
| "이미 다른 로그인 방법으로 가입된 이메일입니다. 다른 로그인 방법을 사용해주세요." | ||
| ); | ||
| } | ||
| } else { | ||
| alert( | ||
| "이미 다른 로그인 방법으로 가입된 계정입니다. 이메일 정보를 가져올 수 없습니다." | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
early return 방식을 해보시는 것도 추천 드립니다.
if depth가 줄어서 코드 가독성이 좋아질 수 있을거에요!!
| const useGoogleLogin = (): { googleLogin: () => Promise<void> } => { | ||
| const navigate = useNavigate(); | ||
|
|
||
| const googleLogin = async (): Promise<void> => { | ||
| try { | ||
| const result = await signInWithPopup(auth, googleProvider); | ||
| const user = result.user; | ||
|
|
||
| console.log("Google 로그인 성공: ", user); | ||
| navigate("/"); | ||
| } catch (error) { | ||
| console.error("Google 로그인 실패: ", error); | ||
| } | ||
| }; | ||
|
|
||
| return { googleLogin }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위에 useGithubLogin과 동일한 로직인거로 보입니다!
hook 인자로 provider를 제공받아 사용하여 재사용성 좋게 관리하면
혹시 나중에 다른 OAuth 서비스를 제공하더라도 같은 로직을 여러번 작성하지 않을 수 있을 것 같습니다!
| const SocialButton = styled(Button)({ | ||
| width: "100%", | ||
| marginBottom: "16px", | ||
| textTransform: "none", | ||
| display: "flex", | ||
| alignItems: "center", | ||
| justifyContent: "center", | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
styled component는 render component export 아래에 선언해주시면 감사하겠습니다 🙇
|
제가 .env 확인까지 하고 갔어야 했는데 ㅠㅠ 고생해주신 사라님 정말정말 감사합니다!! 덕분에 에러없었어요 💪 |
c6fe0af
into
amicable-development-center:develop
개요
이 PR의 목적과 구현 내용을 간단히 설명합니다.
변경 사항
구현 내용
firebase.ts 연동
loginPage 대략적인 ui 구현
개발 후기 및 개선사항
이번 작업에서 배운 점
.env 파일의 위치: root가 항상 src 이지 않음! ㅠㅠ
vite.config.ts 파일 확인하고 진짜 root 가 어디인지 확인 해야함!!
어려웠던 점 / 에로사항
다음에 개선하고 싶은 점
팀원들과 공유하고 싶은 팁