diff --git a/src/main/java/com/dnd/runus/application/oauth/OauthService.java b/src/main/java/com/dnd/runus/application/oauth/OauthService.java index 9cb3a17d..7c46dbf8 100644 --- a/src/main/java/com/dnd/runus/application/oauth/OauthService.java +++ b/src/main/java/com/dnd/runus/application/oauth/OauthService.java @@ -77,7 +77,7 @@ public SignResponse signUp(SignUpRequest request) { } @Transactional(readOnly = true) - public void revokeOauth(long memberId, WithdrawRequest request) { + public boolean revokeOauth(long memberId, WithdrawRequest request) { memberRepository.findById(memberId).orElseThrow(() -> new NotFoundException(Member.class, memberId)); @@ -93,23 +93,19 @@ public void revokeOauth(long memberId, WithdrawRequest request) { String.format( "socialType: %s, oauthId: %s, memberId: %s", request.socialType(), oauthId, memberId))); - Thread.startVirtualThread(() -> { - try { - String accessToken = oidcProvider.getAccessToken(request.authorizationCode()); - oidcProvider.revoke(accessToken); - log.info("토큰 revoke 성공. memberId: {}, socialType: {}", memberId, request.socialType()); - } catch (Exception e) { - log.warn( - "토큰 revoke 실패. memberId: {}, socialType: {}, {}", - memberId, - request.socialType(), - e.getMessage()); - } - }); - log.info("토큰 revoke 요청 완료. memberId: {}, socialType: {}", memberId, request.socialType()); - - AfterTransactionEvent withDrawEvent = () -> memberWithdrawService.deleteAllDataAboutMember(memberId); - eventPublisher.publishEvent(withDrawEvent); + try { + String accessToken = oidcProvider.getAccessToken(request.authorizationCode()); + oidcProvider.revoke(accessToken); + log.info("토큰 revoke 성공. memberId: {}, socialType: {}", memberId, request.socialType()); + + AfterTransactionEvent withDrawEvent = () -> memberWithdrawService.deleteAllDataAboutMember(memberId); + eventPublisher.publishEvent(withDrawEvent); + + return true; + } catch (Exception e) { + log.warn("토큰 revoke 실패. memberId: {}, socialType: {}, {}", memberId, request.socialType(), e.getMessage()); + return false; + } } private SocialProfile createMember(String oauthId, String email, SocialType socialType, String nickname) { diff --git a/src/main/java/com/dnd/runus/presentation/v1/oauth/OauthController.java b/src/main/java/com/dnd/runus/presentation/v1/oauth/OauthController.java index 62930fac..7b6833db 100644 --- a/src/main/java/com/dnd/runus/presentation/v1/oauth/OauthController.java +++ b/src/main/java/com/dnd/runus/presentation/v1/oauth/OauthController.java @@ -8,6 +8,7 @@ import com.dnd.runus.presentation.v1.oauth.dto.request.SignUpRequest; import com.dnd.runus.presentation.v1.oauth.dto.request.WithdrawRequest; import com.dnd.runus.presentation.v1.oauth.dto.response.SignResponse; +import com.dnd.runus.presentation.v1.oauth.dto.response.WithdrawResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; @@ -76,7 +77,9 @@ public SignResponse signUp(@Valid @RequestBody SignUpRequest request) { @ApiErrorType({ErrorType.UNSUPPORTED_SOCIAL_TYPE, ErrorType.FAILED_AUTHENTICATION}) @PostMapping("/withdraw") @ResponseStatus(HttpStatus.OK) - public void withdraw(@MemberId long memberId, @Valid @RequestBody WithdrawRequest request) { - oauthService.revokeOauth(memberId, request); + public WithdrawResponse withdraw(@MemberId long memberId, @Valid @RequestBody WithdrawRequest request) { + boolean isSuccess = oauthService.revokeOauth(memberId, request); + + return new WithdrawResponse(isSuccess); } } diff --git a/src/main/java/com/dnd/runus/presentation/v1/oauth/dto/response/WithdrawResponse.java b/src/main/java/com/dnd/runus/presentation/v1/oauth/dto/response/WithdrawResponse.java new file mode 100644 index 00000000..ccb03867 --- /dev/null +++ b/src/main/java/com/dnd/runus/presentation/v1/oauth/dto/response/WithdrawResponse.java @@ -0,0 +1,6 @@ +package com.dnd.runus.presentation.v1.oauth.dto.response; + +public record WithdrawResponse( + boolean isWithdrawSuccess +) { +}