-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refac] auth 부분 리팩토링 및 response 변경 (#44)
* [refac] oauthHelper 분리 및 회원가입 response 변경 #43 * [feat] 회원 탈퇴 로직 미완 #43 * [refac] url 처리 로직 추가 #43 * [refac] module 의존성 정리 #40 * [refac] 회원 탈퇴 로직 추가 #43
- Loading branch information
Showing
50 changed files
with
338 additions
and
137 deletions.
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
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
69 changes: 54 additions & 15 deletions
69
Api/src/main/java/allchive/server/api/auth/service/WithdrawUserUseCase.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 |
---|---|---|
@@ -1,42 +1,81 @@ | ||
package allchive.server.api.auth.service; | ||
|
||
|
||
import allchive.server.api.auth.service.helper.AppleOAuthHelper; | ||
import allchive.server.api.auth.service.helper.KakaoOauthHelper; | ||
import allchive.server.api.auth.service.helper.OauthHelper; | ||
import allchive.server.api.config.security.SecurityUtil; | ||
import allchive.server.core.annotation.UseCase; | ||
import allchive.server.core.error.exception.InvalidOauthProviderException; | ||
import allchive.server.domain.domains.archiving.adaptor.ArchivingAdaptor; | ||
import allchive.server.domain.domains.archiving.domain.Archiving; | ||
import allchive.server.domain.domains.block.service.BlockDomainService; | ||
import allchive.server.domain.domains.content.adaptor.ContentAdaptor; | ||
import allchive.server.domain.domains.content.adaptor.TagAdaptor; | ||
import allchive.server.domain.domains.content.domain.Tag; | ||
import allchive.server.domain.domains.content.service.ContentDomainService; | ||
import allchive.server.domain.domains.content.service.ContentTagGroupDomainService; | ||
import allchive.server.domain.domains.content.service.TagDomainService; | ||
import allchive.server.domain.domains.recycle.service.RecycleDomainService; | ||
import allchive.server.domain.domains.report.service.ReportDomainService; | ||
import allchive.server.domain.domains.search.service.LatestSearchDomainService; | ||
import allchive.server.domain.domains.user.adaptor.RefreshTokenAdaptor; | ||
import allchive.server.domain.domains.user.adaptor.UserAdaptor; | ||
import allchive.server.domain.domains.user.domain.User; | ||
import allchive.server.domain.domains.user.domain.enums.OauthProvider; | ||
import allchive.server.domain.domains.user.service.ScrapDomainService; | ||
import allchive.server.domain.domains.user.service.UserDomainService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
public class WithdrawUserUseCase { | ||
private final KakaoOauthHelper kakaoOauthHelper; | ||
private final AppleOAuthHelper appleOAuthHelper; | ||
private final UserAdaptor userAdaptor; | ||
private final OauthHelper oauthHelper; | ||
private final RefreshTokenAdaptor refreshTokenAdaptor; | ||
private final LatestSearchDomainService latestSearchDomainService; | ||
private final ScrapDomainService scrapDomainService; | ||
private final BlockDomainService blockDomainService; | ||
private final ArchivingAdaptor archivingAdaptor; | ||
private final TagAdaptor tagAdaptor; | ||
private final ContentTagGroupDomainService contentTagGroupDomainService; | ||
private final ContentDomainService contentDomainService; | ||
private final TagDomainService tagDomainService; | ||
private final RecycleDomainService recycleDomainService; | ||
private final ReportDomainService reportDomainService; | ||
private final UserDomainService userDomainService; | ||
|
||
public void execute(OauthProvider provider) { | ||
public void execute(OauthProvider provider, String appleAccessToken) { | ||
Long userId = SecurityUtil.getCurrentUserId(); | ||
User user = userAdaptor.queryUserById(userId); | ||
// 우리쪽 탈퇴 | ||
refreshTokenAdaptor.deleteTokenByUserId(userId); | ||
User user = userAdaptor.findUserById(userId); | ||
// oauth쪽 탈퇴 | ||
withdrawOauth(provider, appleAccessToken, user); | ||
// 우리쪽 탈퇴 | ||
withdrawService(userId, user); | ||
} | ||
|
||
private void withdrawOauth(OauthProvider provider, String appleAccessToken, User user) { | ||
switch (provider) { | ||
case KAKAO: | ||
kakaoOauthHelper.withdrawKakaoOauthUser(user.getOauthInfo().getOid()); | ||
break; | ||
// case APPLE: | ||
// appleOAuthHelper.withdrawAppleOauthUser(); | ||
default: | ||
throw InvalidOauthProviderException.EXCEPTION; | ||
case KAKAO -> oauthHelper.withdraw(provider, user.getOauthInfo().getOid(), null); | ||
case APPLE -> oauthHelper.withdraw(provider, null, appleAccessToken); | ||
default -> throw InvalidOauthProviderException.EXCEPTION; | ||
} | ||
|
||
} | ||
|
||
private void withdrawService(Long userId, User user) { | ||
refreshTokenAdaptor.deleteTokenByUserId(userId); | ||
latestSearchDomainService.deleteAllByUserId(userId); | ||
scrapDomainService.deleteAllByUser(user); | ||
blockDomainService.queryDeleteBlockByBlockFromOrBlockUser(userId); | ||
List<Archiving> archivingList = archivingAdaptor.findAllByUserId(userId); | ||
List<Long> archivingId = archivingList.stream().map(Archiving::getId).toList(); | ||
List<Tag> tagList = tagAdaptor.findAllByUserId(userId); | ||
contentTagGroupDomainService.deleteAllByTagIn(tagList); | ||
tagDomainService.deleteAll(tagList); | ||
contentDomainService.deleteAllByArchivingIdIn(archivingId); | ||
recycleDomainService.deleteAllByUserId(userId); | ||
reportDomainService.deleteAllByReportedUserId(userId); | ||
userDomainService.deleteUserById(userId); | ||
} | ||
} |
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
Oops, something went wrong.