Skip to content

Commit

Permalink
#24 Feat : 유저 탈퇴시 유저정보 삭제 및 상태 DELETE로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
shinhn committed Jan 13, 2023
1 parent 6c250fd commit 0813025
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ApplicationResponse<TokenResponse> logInApple(@RequestBody AppleLoginReq
@ApiOperation(value = "회원탈퇴")
@PostMapping(value = "/delete/apple")
@ResponseBody
public ApplicationResponse<String> logInApple(@RequestBody DeleteUserReq deleteUserReq) throws NoSuchAlgorithmException {
public ApplicationResponse<String> deleteUserApple(@RequestBody DeleteUserReq deleteUserReq) throws NoSuchAlgorithmException {

appleService.deleteUser(deleteUserReq);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
@AllArgsConstructor
@Data
public class DeleteUserReq {
String identityToken;
Long userId;
String refreshToken;

String identityToken;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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();
}
}
21 changes: 21 additions & 0 deletions server/src/main/java/com/yogit/server/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 0813025

Please sign in to comment.