File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
src/main/java/com/ccapp/ccgo/user Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -60,4 +60,12 @@ public ResponseEntity<Void> changePassword(@Valid @RequestBody PasswordChangeReq
6060 userService .changePassword (passwordChangeRequestDto );
6161 return ResponseEntity .ok ().build ();
6262 }
63+
64+ // 계정 탈퇴
65+ @ DeleteMapping ("/me" )
66+ public ResponseEntity <Void > deleteCurrentUser () {
67+ log .info ("✅ 계정 탈퇴 요청" );
68+ userService .deleteCurrentUser ();
69+ return ResponseEntity .ok ().build ();
70+ }
6371}
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ public class UserUpdateRequestDto {
1717 @ Email (message = "올바른 이메일 형식이 아닙니다." )
1818 private String email ;
1919
20+ // 선택적 필드들 (프론트엔드에서 전송하지 않을 수 있음)
2021 private String birthdate ; // YYYY-MM-DD 형식의 문자열
2122 private String gender ;
2223
Original file line number Diff line number Diff line change @@ -170,4 +170,15 @@ public void changePassword(PasswordChangeRequestDto dto) {
170170
171171 userRepository .save (user );
172172 }
173+
174+ // 11. 현재 사용자 계정 삭제 (탈퇴)
175+ public void deleteCurrentUser () {
176+ Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
177+ String email = authentication .getName ();
178+
179+ User user = userRepository .findByEmail (email )
180+ .orElseThrow (() -> new CustomException ("로그인한 사용자를 찾을 수 없습니다." , HttpStatus .NOT_FOUND ));
181+
182+ userRepository .delete (user );
183+ }
173184}
You can’t perform that action at this time.
0 commit comments