Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/com/capstone/favicon/config/CorsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public CorsConfigurationSource corsConfigurationSource() {
configuration.addAllowedOrigin("http://127.0.0.1:3000");
configuration.addAllowedOrigin("http://localhost:3001");
configuration.addAllowedOrigin("http://127.0.0.1:3001");
configuration.addAllowedOrigin("http://3.35.26.19");
configuration.addAllowedHeader("*");
configuration.addAllowedMethod("*");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ public void delete(HttpServletRequest request) {
userRepository.delete(user);
}

@Override
public void deleteById(Long id) {
User user = userRepository.findByUserId(id);
if (user == null) {
throw new IllegalArgumentException("존재하지 않는 사용자입니다.");
}
userRepository.delete(user);
}


@Override
public boolean checkAdmin(HttpServletRequest request) {
HttpSession session = request.getSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public interface UserService {
void logout(HttpServletRequest request);
void delete(HttpServletRequest request);
boolean checkAdmin(HttpServletRequest request);
void deleteById(Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ public ResponseEntity<APIResponse<?>> deleteUser(HttpServletRequest request) {
}
}

@DeleteMapping("/delete-account/{id}")
public ResponseEntity<APIResponse<?>> deleteUser(@PathVariable Long id) {
try {
userService.deleteById(id);
return ResponseEntity.ok().body(APIResponse.successAPI("탈퇴하였습니다.", null));
} catch (Exception e) {
String message = e.getMessage();
return ResponseEntity.badRequest().body(APIResponse.errorAPI(message));
}
}


@GetMapping("/session-check")
public ResponseEntity<APIResponse<?>> checkSession(HttpServletRequest request) {
try {
Expand Down
Loading