diff --git a/src/main/java/com/example/reddiserver/auth/service/OAuthService.java b/src/main/java/com/example/reddiserver/auth/service/OAuthService.java index 15eaff0..fc8c590 100644 --- a/src/main/java/com/example/reddiserver/auth/service/OAuthService.java +++ b/src/main/java/com/example/reddiserver/auth/service/OAuthService.java @@ -80,9 +80,13 @@ public LoginResponseDto login(String code, String redirectUri) { public Long getUserId() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication != null) { - CustomAuthenticationDetails customDetails = (CustomAuthenticationDetails) authentication.getDetails(); - return customDetails.getUserId(); + Object details = authentication.getDetails(); + if (details instanceof CustomAuthenticationDetails) { + CustomAuthenticationDetails customDetails = (CustomAuthenticationDetails) details; + return customDetails.getUserId(); + } } return null; // 인증 정보가 없거나 CustomAuthenticationDetails를 사용하지 않는 경우 diff --git a/src/main/java/com/example/reddiserver/controller/ChatGptController.java b/src/main/java/com/example/reddiserver/controller/ChatGptController.java index e736fb1..9a3a835 100644 --- a/src/main/java/com/example/reddiserver/controller/ChatGptController.java +++ b/src/main/java/com/example/reddiserver/controller/ChatGptController.java @@ -23,7 +23,6 @@ public class ChatGptController { private final ChatGptService chatGptService; private final OAuthService oAuthService; - @SecurityRequirement(name = "Authorization") @Operation(summary = "ChatGPT로 원하는 브랜드 만들기") @PostMapping("/question") public ApiResponse postChat(@RequestBody ChatGptRequest chatGptRequest) throws JsonProcessingException {