Skip to content

Week5/nonshaman-m3#54

Open
nonshaman wants to merge 12 commits into
mainfrom
week5/nonshaman-m3
Open

Week5/nonshaman-m3#54
nonshaman wants to merge 12 commits into
mainfrom
week5/nonshaman-m3

Conversation

@nonshaman
Copy link
Copy Markdown
Collaborator

📚 주차 / 미션

  • 5주차 3번째 미션

📌 작업 내용

-social login google 구현하기

✨ 상세 작업 내용

  • OAuth 2.0 인증 방식 사용
  • 구글 로그인 연동 작업

✅ 체크리스트

  • [o] 기능 정상 작동 확인
  • [o] 불필요한 주석 삭제
  • [o] 해당 주차 키워드 내용 이해

Copy link
Copy Markdown
Collaborator

@yewon20804 yewon20804 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5주차 미션3도 수고하셨습니다 🎉 구글 소셜로그인을 진행하셨고, 코멘트 내용만 추가된다면 더 완성도 높은 코드가 될 것 같습니다 !


토큰이 없을 때 에러 처리

// 현재
if (accessToken) {
    setAccessToken(accessToken);
    setRefreshToken(refreshToken);
    window.location.href = "/mypage";
}

현재 토큰이 없는 경우 아무런 동작을 하지 않아 구글 로그인 리다이렉트 화면에 머물게 되는데요 !
실패 시 로그인 페이지로 리다이렉트하는 처리를 추가하시는 걸 추천드립니다 👍

// 개선
if (accessToken) {
    setAccessToken(accessToken);
    setRefreshToken(refreshToken);
    window.location.href = "/mypage";
} else {
    window.location.href = "/login";
}

refreshToken이 null일 때도 저장 시도

setRefreshToken(refreshToken);

현재 조건으로 accessToken만 체크하고 refreshToken은 별도로 검증하지 않아서, URL에 refreshToken이 없는 경우 null 값이 localStorage에 저장될 수 있습니다 ! refreshToken도 null 여부를 확인한 후 저장하면 더 안전한 코드가 될 것 같습니다 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants