-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor/#220 회원 탈퇴 로직 리팩터링 #227
Open
1o18z
wants to merge
15
commits into
dev
Choose a base branch
from
refactor/#220
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3ce3410
refactor: 탈퇴한 회원 검사 스케줄링 적용
1o18z 45db551
refactor: 회원 탈퇴 정책 로직 작
1o18z 4b77e6a
refactor: 소셜 탈퇴 로직 작성
1o18z 8479672
refactor: 탈퇴 로직 파라미터 변경
1o18z b43e373
refactor: 탈퇴 로직 및 재로그인 로직 수정
1o18z c478db6
style: OAuth 등록/탈퇴 클래스명 변경
1o18z 67f2132
refactor: 탈퇴 후 재로그인 로직 수정
1o18z 3701f61
style: 컨벤션 정리
1o18z fd95006
refactor: 스케쥴러 설정 변경
1o18z 6dcf780
refactor: 회원 탈퇴 로직 OAuthService로 이동
1o18z fae7176
refactor: 유저 프로필 관련 로직 서비스 분리
1o18z e4cc021
refactor: 메서드 변경 및 회원 탈퇴 날짜 비교 로직 수정
1o18z 39b4833
test: 회원 탈퇴 테스트 코드 작성
1o18z f7b4a7b
refactor: 스케줄러 설정 어노테이션 위치 변경
1o18z 45ee793
refactor: 유저 탈퇴 및 가입 로직 수정
1o18z File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/coffeemeet/server/common/config/SchedulingConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package coffeemeet.server.common.config; | ||
|
||
import coffeemeet.server.user.service.UserService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class SchedulingConfig { | ||
|
||
private final UserService userService; | ||
|
||
@Scheduled(cron = "0 0 3 * * *") | ||
public void checkUserDeleted() { | ||
log.info("탈퇴 후 30일이 지난 회원 정보 제거"); | ||
userService.deleteUserInfos(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/coffeemeet/server/oauth/implement/client/OAuthMemberUnlinkRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package coffeemeet.server.oauth.implement.client; | ||
|
||
import static coffeemeet.server.auth.exception.AuthErrorCode.INVALID_LOGIN_TYPE; | ||
|
||
import coffeemeet.server.common.execption.InvalidAuthException; | ||
import coffeemeet.server.oauth.infrastructure.OAuthUnlinkDetail; | ||
import coffeemeet.server.user.domain.OAuthProvider; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class OAuthMemberUnlinkRegistry { | ||
|
||
private static final String INVALID_LOGIN_TYPE_MESSAGE = "로그인 타입(%s)에 일치하는 타입이 없습니다."; | ||
|
||
private final Map<OAuthProvider, OAuthUnlinkClient> mapping; | ||
|
||
public OAuthMemberUnlinkRegistry(Set<OAuthUnlinkClient> details) { | ||
this.mapping = details.stream().collect( | ||
Collectors.toUnmodifiableMap(OAuthUnlinkClient::oAuthProvider, Function.identity()) | ||
); | ||
} | ||
|
||
public OAuthUnlinkDetail unlink(OAuthProvider oAuthProvider, String accessToken) { | ||
return getClient(oAuthProvider).unlink(accessToken); | ||
} | ||
|
||
private OAuthUnlinkClient getClient(OAuthProvider oAuthProvider) { | ||
return Optional.ofNullable(mapping.get(oAuthProvider)) | ||
.orElseThrow(() -> new InvalidAuthException( | ||
INVALID_LOGIN_TYPE, | ||
String.format(INVALID_LOGIN_TYPE_MESSAGE, oAuthProvider)) | ||
); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/coffeemeet/server/oauth/implement/client/OAuthUnlinkClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package coffeemeet.server.oauth.implement.client; | ||
|
||
import coffeemeet.server.oauth.infrastructure.OAuthUnlinkDetail; | ||
import coffeemeet.server.user.domain.OAuthProvider; | ||
|
||
public interface OAuthUnlinkClient { | ||
|
||
OAuthProvider oAuthProvider(); | ||
|
||
OAuthUnlinkDetail unlink(String accessToken); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/coffeemeet/server/oauth/infrastructure/OAuthUnlinkDetail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package coffeemeet.server.oauth.infrastructure; | ||
|
||
public record OAuthUnlinkDetail( | ||
Long id, | ||
String accessToken, | ||
String result | ||
) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/coffeemeet/server/oauth/infrastructure/kakao/KakaoUnlinkClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package coffeemeet.server.oauth.infrastructure.kakao; | ||
|
||
import static coffeemeet.server.oauth.utils.constant.OAuthConstant.AUTHORIZATION; | ||
import static coffeemeet.server.oauth.utils.constant.OAuthConstant.BEARER_TYPE; | ||
|
||
import coffeemeet.server.oauth.implement.client.OAuthUnlinkClient; | ||
import coffeemeet.server.oauth.infrastructure.OAuthUnlinkDetail; | ||
import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoUnlinkDetail; | ||
import coffeemeet.server.user.domain.OAuthProvider; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
|
||
import org.springframework.http.HttpMethod; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class KakaoUnlinkClient implements OAuthUnlinkClient { | ||
|
||
private static final String UNLINK_USER_URL = "https://kapi.kakao.com/v1/user/unlink"; | ||
|
||
private final RestTemplate restTemplate; | ||
|
||
@Override | ||
public OAuthProvider oAuthProvider() { | ||
return OAuthProvider.KAKAO; | ||
} | ||
|
||
public OAuthUnlinkDetail unlink(String accessToken) { | ||
HttpHeaders httpHeaders = new HttpHeaders(); | ||
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
httpHeaders.set(AUTHORIZATION, BEARER_TYPE + accessToken); | ||
|
||
HttpEntity<?> request = new HttpEntity<>(httpHeaders); | ||
|
||
KakaoUnlinkDetail response = restTemplate.exchange(UNLINK_USER_URL, HttpMethod.POST, request, | ||
KakaoUnlinkDetail.class).getBody(); | ||
|
||
assert response != null; | ||
return response.toOAuthUnlinkDetail(); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/coffeemeet/server/oauth/infrastructure/kakao/dto/KakaoUnlinkDetail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package coffeemeet.server.oauth.infrastructure.kakao.dto; | ||
|
||
import coffeemeet.server.oauth.infrastructure.OAuthUnlinkDetail; | ||
|
||
public record KakaoUnlinkDetail(Long userId) { | ||
|
||
public OAuthUnlinkDetail toOAuthUnlinkDetail() { | ||
return new OAuthUnlinkDetail(this.userId(), null, null); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/coffeemeet/server/oauth/infrastructure/naver/NaverUnlinkClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package coffeemeet.server.oauth.infrastructure.naver; | ||
|
||
import static coffeemeet.server.oauth.utils.constant.OAuthConstant.AUTHORIZATION; | ||
import static coffeemeet.server.oauth.utils.constant.OAuthConstant.AUTHORIZATION_CODE; | ||
import static coffeemeet.server.oauth.utils.constant.OAuthConstant.BEARER_TYPE; | ||
import static coffeemeet.server.oauth.utils.constant.OAuthConstant.CLIENT_ID; | ||
import static coffeemeet.server.oauth.utils.constant.OAuthConstant.CLIENT_SECRET; | ||
import static coffeemeet.server.oauth.utils.constant.OAuthConstant.GRANT_TYPE; | ||
|
||
import coffeemeet.server.oauth.config.naver.NaverProperties; | ||
import coffeemeet.server.oauth.implement.client.OAuthUnlinkClient; | ||
import coffeemeet.server.oauth.infrastructure.OAuthUnlinkDetail; | ||
import coffeemeet.server.oauth.infrastructure.naver.dto.NaverUnlinkDetail; | ||
import coffeemeet.server.user.domain.OAuthProvider; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class NaverUnlinkClient implements OAuthUnlinkClient { | ||
|
||
private static final String UNLINK_USER_URL = "https://nid.naver.com/oauth2.0/token"; | ||
|
||
private final RestTemplate restTemplate; | ||
private final NaverProperties naverProperties; | ||
|
||
@Override | ||
public OAuthProvider oAuthProvider() { | ||
return OAuthProvider.NAVER; | ||
} | ||
|
||
public OAuthUnlinkDetail unlink(String accessToken) { | ||
HttpHeaders httpHeaders = new HttpHeaders(); | ||
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
|
||
httpHeaders.set(AUTHORIZATION, BEARER_TYPE + accessToken); | ||
httpHeaders.set(CLIENT_ID, naverProperties.getClientId()); | ||
httpHeaders.set(CLIENT_SECRET, naverProperties.getClientSecret()); | ||
httpHeaders.set(GRANT_TYPE, AUTHORIZATION_CODE); | ||
|
||
HttpEntity<?> request = new HttpEntity<>(httpHeaders); | ||
|
||
NaverUnlinkDetail response = restTemplate.exchange(UNLINK_USER_URL, HttpMethod.POST, request, | ||
NaverUnlinkDetail.class).getBody(); | ||
|
||
assert response != null; | ||
return response.toOAuthUnlinkDetail(); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/coffeemeet/server/oauth/infrastructure/naver/dto/NaverUnlinkDetail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package coffeemeet.server.oauth.infrastructure.naver.dto; | ||
|
||
import coffeemeet.server.oauth.infrastructure.OAuthUnlinkDetail; | ||
|
||
public record NaverUnlinkDetail( | ||
String accessToken, | ||
String result | ||
) { | ||
|
||
public OAuthUnlinkDetail toOAuthUnlinkDetail() { | ||
return new OAuthUnlinkDetail(null, this.accessToken, this.result); | ||
} | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ScheduleConfig에 붙여주세요