diff --git a/server/src/main/java/com/yogit/server/applelogin/controller/AppleController.java b/server/src/main/java/com/yogit/server/applelogin/controller/AppleController.java index cdad9e1..2f3948c 100644 --- a/server/src/main/java/com/yogit/server/applelogin/controller/AppleController.java +++ b/server/src/main/java/com/yogit/server/applelogin/controller/AppleController.java @@ -66,7 +66,7 @@ public ApplicationResponse logInApple(@RequestBody AppleLoginReq @ApiOperation(value = "회원탈퇴") @PostMapping(value = "/delete/apple") @ResponseBody - public ApplicationResponse logInApple(@RequestBody DeleteUserReq deleteUserReq) throws NoSuchAlgorithmException { + public ApplicationResponse deleteUserApple(@RequestBody DeleteUserReq deleteUserReq) throws NoSuchAlgorithmException { appleService.deleteUser(deleteUserReq); diff --git a/server/src/main/java/com/yogit/server/applelogin/model/DeleteUserReq.java b/server/src/main/java/com/yogit/server/applelogin/model/DeleteUserReq.java index 0f48069..b010d05 100644 --- a/server/src/main/java/com/yogit/server/applelogin/model/DeleteUserReq.java +++ b/server/src/main/java/com/yogit/server/applelogin/model/DeleteUserReq.java @@ -8,6 +8,8 @@ @AllArgsConstructor @Data public class DeleteUserReq { - String identityToken; + Long userId; String refreshToken; + + String identityToken; } diff --git a/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java b/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java index b5ca78e..77b207c 100644 --- a/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java +++ b/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java @@ -146,7 +146,7 @@ public String getPayload(String id_token) { // return null; // } - public void deleteUser(DeleteUserReq deleteUserReq) throws NoSuchAlgorithmException { + public void deleteUser(DeleteUserReq deleteUserReq) { RestTemplate restTemplate = new RestTemplateBuilder().build(); String revokeUrl = "https://appleid.apple.com/auth/revoke"; @@ -162,6 +162,9 @@ public void deleteUser(DeleteUserReq deleteUserReq) throws NoSuchAlgorithmExcept restTemplate.postForEntity(revokeUrl, httpEntity, String.class); - // TODO 유저 정보 삭제 (개인정보 삭제 및 status -> DELETE 로 변경) + // 유저 정보 삭제 및 유저 상태 변경 (DELETE) + userService.validateRefreshToken(deleteUserReq.getUserId(), deleteUserReq.getRefreshToken()); + User user = userRepository.findByUserId(deleteUserReq.getUserId()).orElseThrow(() -> new NotFoundUserException()); + user.deleteUser(); } } diff --git a/server/src/main/java/com/yogit/server/user/entity/User.java b/server/src/main/java/com/yogit/server/user/entity/User.java index 79a53da..fbaca30 100644 --- a/server/src/main/java/com/yogit/server/user/entity/User.java +++ b/server/src/main/java/com/yogit/server/user/entity/User.java @@ -175,4 +175,25 @@ public void addDeviceToken(String deviceToken){ public void changeUserStatus(UserStatus userStatus){ this.userStatus = userStatus; } + + public void deleteUser(){ + this.loginId = null; + this.name = null; + this.profileImg = null; + this.aboutMe = null; + this.longtitude = null; + this.latitude = null; + this.job = null; + this.age = null; + this.memberTemp = null; + this.phoneNum = null; + this.gender = null; + this.nationality = null; + this.refreshToken = null; + this.reportingCnt = null; + this.reportedCnt = null; + this.deviceToken = null; + + userStatus = UserStatus.DELETE; + } }