-
Notifications
You must be signed in to change notification settings - Fork 2
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: 카카오 로그아웃 API 구현 #70
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.
로그아웃 잘 구현 하였습니다!
잘 모르는 부분이기에 질문을 중심으로 코멘트 남겼습니다!
User user = User.initialCreate( | ||
kakaoMember.id(), | ||
kakaoMember.kakaoAccount().email(), | ||
kakaoTokenResponse.accessToken() | ||
); |
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.
해당부분은 kakao에서 가져온 카카오 유저가 실제 우리 서비스에 가입한 유저가 아니면 회원가입을 시키는 과정인거죠!? 그리고 로그아웃을 위해 accessToken저장을 위해 별도 추가하신거고
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.
정확합니다!
@PatchMapping("/auth/kakao") | ||
ResponseEntity<Void> logout(@RequestHeader(value = AUTHORIZATION) String accessToken) { | ||
authService.logout(accessToken); | ||
return ResponseEntity.noContent().build(); |
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.
이부분은 프론트단이 accessToken가지고 해당 uri로 요청하는 거죠?
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.
맞습니다!
public void logout(String accessToken) { | ||
Long userId = jwtManager.read(accessToken); | ||
User user = userRepository.getById(userId); | ||
kakaoOauthClient.logout(user.getKakaoAccessToken()); | ||
} |
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.
아하 카카오에서 발급한 AccessToken을 테이블에 저장한 이유가 여기있었군요
@@ -28,18 +24,17 @@ public class UserService { | |||
|
|||
@Transactional(readOnly = true) | |||
public UserInfoResponse getUserInfo(Long userId, String accessToken) { | |||
Optional<User> found = userRepository.findById(userId); | |||
User foundUser = found.orElseThrow(() -> new CustomException(NOT_FOUND)); | |||
User user = userRepository.getById(userId); |
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.
findById를 안하고 getById 하신 이유가 있나요!?
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.
service 단의 코드 간소화를 위해 했습니다.
Description
카카오 로그아웃 API 구현했습니다.
로그아웃 요청 시, 액세스 토큰 방식과 서비스 앱 어드민 키 방식으로 총 2가지 방식이 존재합니다.
서비스 앱 어드민 키 방식보다 액세스 토큰 방식이 쉽고 편하게 구현이 가능한 대신, 카카오에서 발급한 액세스 토큰을 DB에 저장해야 합니다.
아직 개발 단계이며 데이터가 많이 쌓이지 않았으므로 users 테이블에 함께 저장하도록 했습니다.
하지만 추후 따로 관리 할 필요가 있어보이며 해당 방법에 대해서는 고민해봐야겠습니다.
Reference
Relation Issues