Skip to content

Commit

Permalink
[FIX]#14 회원 탈퇴 응답 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
LEEJaeHyeok97 committed Aug 29, 2023
1 parent 1be35d5 commit c1aa147
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public String signIn(SignInReq signInReq) {

// 유저 정보 논리 삭제
public String deleteUser(String token) {


String subtractedEmail = JwtUtil.getUserEmail(token, secret_key);

Optional<User> user = userRepository.findByEmail(subtractedEmail);
Expand All @@ -85,6 +87,6 @@ public String deleteUser(String token) {

userRepository.save(tmpUser);

return "finish";
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,18 @@ public ResponseEntity<String> updateProfile(

// 유저 정보 탈퇴(논리 삭제)
@PatchMapping("/delete")
public ResponseEntity<String> deleteUser(
public ResponseEntity<BaseResponse<?>> deleteUser(
@RequestHeader("Authorization") String authorization
) {
String token = authorization.substring(7);
String t = userService.deleteUser(token);

try {
String token = authorization.substring(7);
String t = userService.deleteUser(token);

return ResponseEntity.ok().body(t);
return ResponseEntity.ok(BaseResponse.success(SuccessCode.LOGICAL_DELETE_SUCCESS));
} catch (Exception e) {
return ResponseEntity.ok().body(BaseResponse.error(ErrorCode.EXPIRED_TOKEN));
}
}


Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/example/rcp1/global/SuccessCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public enum SuccessCode {
// CUSTOM_CREATED_SUCCESS(CREATED, "~ 생성에 성공했습니다.");
SIGNUP_SUCCESS(OK, "회원가입에 성공했습니다."),
SIGNIN_SUCCESS(OK, "로그인에 성공했습니다."),
UPDATE_PROFILE_SUCCESS(OK, "프로필이 성공적으로 수정되었습니다.");
UPDATE_PROFILE_SUCCESS(OK, "프로필이 성공적으로 수정되었습니다."),
LOGICAL_DELETE_SUCCESS(OK, "논리적으로 삭제 되었습니다.");

private final HttpStatus httpStatus;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse

// 토큰 만료 여부 확인
if (JwtUtil.isExpired(token, secretKey)) {
log.error("토큰이 만료되었습니다.");
log.error("유효하지 않은 액세스 토큰입니다.");
filterChain.doFilter(request, response);
return;
}
Expand Down

0 comments on commit c1aa147

Please sign in to comment.