Skip to content
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

로그인 로직 개발 #53

Merged
merged 93 commits into from
Jan 7, 2025
Merged

로그인 로직 개발 #53

merged 93 commits into from
Jan 7, 2025

Conversation

sjhjack
Copy link
Contributor

@sjhjack sjhjack commented Dec 29, 2024

📑 개요

✅ PR 체크리스트


  • 🔀 PR 제목의 형식을 잘 작성했나요?
  • 💯 테스트는 잘 통과했나요?
  • 🏗️ 빌드는 성공했나요?
  • 🧹 불필요한 코드는 제거했나요?
  • 💭 이슈는 등록했나요?
  • 🏷️ 라벨은 등록했나요?

🚀 상세 작업 내용


  • UserInfo 요청 Google API 추가
  • Birthday 요청 Google API 추가
    • 생일 비공개 유저 저장 로직 추가
  • GoogleOAuthClient 모듈의 public 메서드에 설명 주석 추가
  • AuthController, AuthService 작성
  • 로그인/회원가입 기능 구현
    • 로그인/회원가입 분기 처리
      • DB 조회 O : 로그인 처리 (토큰 정보 저장)
      • DB 조회 X : 회원가입 처리 (회원 정보, 토큰 정보 저장)
  • 토큰 재발급 기능 구현
    • 토큰 유효성 검증 분기 처리
      • Redis 조회 O : 토큰 재발급 에러 (401)
      • Redis 조회 X : 잘못된 토큰 에러 (400)
  • 회원 탈퇴 기능 구현
    • Redis에서 토큰 정보 삭제
    • 회원 정보 Hard Delete -> 추후 논의 후 변경 예정
  • Redis Token 모듈 작성
    • {key : value} = {access_token : refresh_token} 으로 저장 (refresh_token 만료기한 만큼)
    • 토큰 정보 저장, 삭제, 조회 기능 작성
  • 전체 테스트 코드 작성

📁 ETC


closed: #41

@sjhjack sjhjack linked an issue Dec 29, 2024 that may be closed by this pull request
8 tasks
Copy link
Member

@KIMSEI1124 KIMSEI1124 left a comment

Choose a reason for hiding this comment

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

해당 이슈 처리하시느라 고생하셨습니다! 👍🏼

몇 가지가지 궁금한 사항들작성해 두었고었수정해야 하는하는 목록에 대해서도 코멘트를 달아두었습니다!
하시다가 궁금하신 내용이 있다질문해 주시면시면 감사합니다!

Comment on lines 61 to 64
assertThat(result.getId()).isEqualTo(findSocialMember.getId());
assertThat(result.getMember().getMemberId()).isEqualTo(findSocialMember.getMember().getMemberId());
assertThat(result.getOauthId()).isEqualTo(findSocialMember.getOauthId());
assertThat(result.getOauthProvider()).isEqualTo(findSocialMember.getOauthProvider());
Copy link
Member

Choose a reason for hiding this comment

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

이렇게 하나씩 하는 것 보다 재귀적으로 확인할 수 있는 테스트 방법이 있습니다!

해당 방법으로 수정해보시고, 발생하는 문제점을 해결해보시면 좋을 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

확인해보니 isEqualTo() 메서드는 Object끼리 비교가 가능하여 assertThat(result).isEqualTo(findSocialMember) 으로 수정했습니다!
의도하신 방법이 맞을까요?

Copy link
Member

@KIMSEI1124 KIMSEI1124 Jan 1, 2025

Choose a reason for hiding this comment

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

다른 방법을 의도하였는데! 해당 방법으로 성공이 되었군요! 아마도 BaseEntityextends 하지 않아서 그런 것 같습니다!

assertThat(foundMember)
				.usingRecursiveComparison()
				.ignoringFields("created", "lastModified")
				.isEqualTo(savedMember);

다음과 같이 객체 내부의 필드 값들에 대해서 재귀적으로 검증하면서 일부 검증이 불필요한 내용을 제외하는 방법이 있습니다! 추후 다른 테스트를 진행하실 때 사용해 보면 좋을 것 같아요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

이런 방법도 있었군요! 배워갑니다. 감사합니다 😄

Comment on lines +10 to +13
public static SocialMember getSocialMember(SocialMemberRepository socialMemberRepository, String id) {
return socialMemberRepository.findByOauthProviderAndOauthId(OauthProvider.GOOGLE, id)
.orElseThrow(() -> new MemberException(MemberErrorCode.NO_SUCH_MEMBER));
}
Copy link
Member

Choose a reason for hiding this comment

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

해당 내용을 보아하니 구글에 종속이 되어 보입니다!

만약 다른 로그인 방식이 생긴다면 어떻게 처리하실건가요?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

좋은 지적 감사합니다!
현재 생각으로는 OauthProvider를 파라미터로 전달받도록 할 것 같습니다.
메서드를 사용하는 모든 곳에서 수정해야 한다는 번거로움이 있지만, 아직 다른 방법이 떠오르지 않습니다 😢

혹시 고려해볼 방법이 있을까요?

Copy link
Member

Choose a reason for hiding this comment

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

사실 파라미터를 제외하면 생각할 방법이 메서드의 이름에다 어떤 제공자에게 인증을 받았는지 적어주는 방법이 생각납니다!

public static SocialMember getSocialMemberByGoogle(SocialMemberRepository socialMemberRepository, String id) {
    return socialMemberRepository.findByOauthProviderAndOauthId(OauthProvider.GOOGLE, id)
	.orElseThrow(() -> new MemberException(MemberErrorCode.NO_SUCH_MEMBER));
}

하지만 새로운 제공자가 생기면 메서드가 하나씩 늘어난다는 단점이 있습니다! 한번 고민해 보시고 선택하면 좋을 것 같아요!

Comment on lines +12 to +13
// Todo : Access Level 고민해보자
// @AllArgsConstructor
Copy link
Member

Choose a reason for hiding this comment

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

주석 내용을 해결해주시면 감사합니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AllArgsConstructor가 인식되지 않는 원인을 아직 해결하지 못해서 해당 부분 주석 처리 후 생성자를 명시적으로 추가해놓은 상태입니다.
해결하는 대로 더 고민해보겠습니다!

@sjhjack sjhjack requested a review from KIMSEI1124 January 1, 2025 09:33
Copy link

github-actions bot commented Jan 3, 2025

📄 Jacoco Coverage Report

Overall Project 92.77% 🍏

There is no coverage information present for the Files changed

Copy link
Member

@KIMSEI1124 KIMSEI1124 left a comment

Choose a reason for hiding this comment

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

전체적으로 잘 된 것 같습니다!!

해당 이슈 개발하느라 엄청 고생많으셨습니다! 👍🏼
먼저 Approve를 해두었습니다! 몇몇 희망사항을 적어봤는데 한번 봐주시면 좋을 것 같습니다!


@Transactional
public void quitMember(AuthMember authMember) {
// Todo : 회원 탈퇴 로직 논의
Copy link
Member

Choose a reason for hiding this comment

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

해당 논의가 필요하다는 내용으로 이슈를 하나 만들어주세요! 👍🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

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

정리해서 올려보겠습니다!

@AutoConfigureRestDocs
// @AutoConfigureMockMvc
// @SpringBootTest
@WebMvcTest(AuthController.class)
Copy link
Member

Choose a reason for hiding this comment

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

Good! 따로 작성하신 문서를 봤는데 잘 해결하신 것 같아요!

그렇다면 @ControllerTest 와 같은 어노테이션을 만들어서 처리할 수 있을 것 같은데 따로 이슈를 만들어서 해결해보는건 어떨까요?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

좋은 의견입니다!
두 어노테이션을 합해서 만들어보겠습니다.

Dto의 의도가 명확하지 않다는 피드백을 반영하여 아래와 같이 변경했습니다.
- MemberDto -> MemberSaveDto
- SocialMemberDto -> SocialMemberSaveDto
실행 속도는 느려지지만 최신 상태에서 테스트 하는 것이 더 중요하다고 생각하여 clean 명령어 추가
Copy link

github-actions bot commented Jan 5, 2025

📄 Jacoco Coverage Report

Overall Project 92.77% 🍏

There is no coverage information present for the Files changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

로그인 관련 비즈니스 로직 작성한다.
2 participants