-
Notifications
You must be signed in to change notification settings - Fork 7
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
구글 로그인, apple로그인 구현, 기존 카카오톡 로그인 사용자를 위한 데이터 이전 로직 구현 #606
Conversation
오 그래도 문제 해결 방법을 찾은 것 같네요 |
지원 가능한 백엔드 등장 |
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.
구글 oauth 관련 문제로 고생 많으셨습니다. 👍
export const getLastDarakbangId = () => { | ||
const lastDarakbangId = localStorage.getItem(LAST_DARAKBANG_ID_KEY); | ||
if (!lastDarakbangId || process.env.MSW === 'true') return null; | ||
if (!lastDarakbangId) return null; | ||
else if (process.env.MSW === 'true') return 0; | ||
return +lastDarakbangId; | ||
}; |
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.
msw 환경에서 반환값을 0으로 별도 처리한 이유가 있나요??
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.
0번째 다락방을 접속한다는 의미였습니다. MSW에서 접속하는 다락방이 0입니다.
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.
만약 기존 localStorage에 0이 아니라 다른 값이 저장되어있다면 제대로 모킹되지 않습니다.
window.google.accounts.id.renderButton( | ||
document.getElementById('g_id_signin'), | ||
{ theme: 'outline', size: 'large', width: 269 }, | ||
); |
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.
useRef 훅을 써보는 건 어떨까요???
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.
확인해볼게요
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.
사용했는데 그것보다 html 스크립트가 google login관련 코드가 준비되기전에 버튼을 렌더하려는 문제 때문에 버튼이 그려지지 않는 것 같아요
PR의 목적이 무엇인가요?
기존의 카카오톡 로그인을 더이상 지원하지 않고 apple로그인과 구글 로그인을 지원하게 되었다. 이를 구현하고, 기존 카카오톡 로그인 사용자를 위해 데이터 이전 로직이 필요하다.
이슈 ID는 무엇인가요?
설명
구글 로그인과 애플 로그인을 구현하였다. 애플 로그인의 경우 기존 카카오톡 로그인과 같은 oauth2.0을 수동으로 구현하였다.
흐름은
와 같이 진행된다.
이와 다르게 구글 로그인에 경우, oauth2.0을 수동으로 구현할 수 있었으나, 서버에서 code를 검증할 때 문제가 파악할 수 없는 문제가 발생하여
https://developers.google.com/identity/gsi/web/guides/overview
다음 링크를 통한 방식으로 구현하게 되었다.
GIS(Google Identity Services)를 이용하여 로그인을 하는데 설명을 읽어보면
라고한다. 실제로 로그인 버튼을 구글에서 제공하는 버튼으로 넣기만 하면 자동으로 JWT로 암호화된 idToken을 가져온다.
이 idToken을 서버로 보내면 로그인이 된다.
다만 현재 이 방식에서도 문제가 발생한다.
간혈적으로 구글 로그인 버튼이 사라지는 문제인데
dev.mouda.site에서 처음 접속했을 때는 정상적으로 로그인버튼이 보인다. 이때 새로고침을 하게 되면 로그인 버튼이 사라지게 된다. 그리고 개발자 모드를 킨 상태에서는 로그인 버튼이 보인다. 해당 문제가 발생하는데 도데체 왜 이런 문제가
발생하는 문제가 생긴다.
프론트 인원 중 시간이 있는 인원에게 도움을 청한다. PR을 쓰는 시점에도 왜 이런 문제가 발생하는지 모르겠다.
2024-10-05.12.mp4
다음은 기존 사용자의 데이터 이전을 위한 로직이다.
해당 로직은 아래의 문서로 제출하겠다.
https://successful-jeep-771.notion.site/e598b8b22f8643eea759859d0df35aad?pvs=4
질문 혹은 공유 사항 (Optional)
간혈적으로 구글 로그인 버튼이 사라지는 문제인데
dev.mouda.site에서 처음 접속했을 때는 정상적으로 로그인버튼이 보인다. 이때 새로고침을 하게 되면 로그인 버튼이 사라지게 된다. 그리고 개발자 모드를 킨 상태에서는 로그인 버튼이 보인다. 해당 문제가 발생하는데 도데체 왜 이런 문제가
발생하는 문제가 생긴다.
프론트 인원 중 시간이 있는 인원에게 도움을 청한다. PR을 쓰는 시점에도 왜 이런 문제가 발생하는지 모르겠다.
역시 stackoverflow는 신이다. 찬양하도록 하자
https://stackoverflow.com/questions/70993933/why-does-the-sign-in-with-google-button-disappear-after-i-render-it-the-second-t
이것으로 해결할 수 있는지 일요일쯤 다시 테스트해보도록 하겠다.