diff --git a/src/main/java/the_monitor/application/service/AccountService.java b/src/main/java/the_monitor/application/service/AccountService.java index 724b0f3..f79a9be 100644 --- a/src/main/java/the_monitor/application/service/AccountService.java +++ b/src/main/java/the_monitor/application/service/AccountService.java @@ -21,7 +21,7 @@ public interface AccountService { String accountSignUp(AccountSignUpRequest request); - String accountSignIn(AccountSignInRequest request, HttpServletResponse response, HttpSession session); + ApiResponse accountSignIn(AccountSignInRequest request, HttpServletResponse response, HttpSession session); String checkEmail(String email); diff --git a/src/main/java/the_monitor/application/serviceImpl/AccountServiceImpl.java b/src/main/java/the_monitor/application/serviceImpl/AccountServiceImpl.java index d96b3e1..f098f63 100644 --- a/src/main/java/the_monitor/application/serviceImpl/AccountServiceImpl.java +++ b/src/main/java/the_monitor/application/serviceImpl/AccountServiceImpl.java @@ -109,12 +109,15 @@ public String accountSignUp(AccountSignUpRequest request) { } @Override - public String accountSignIn(AccountSignInRequest request, HttpServletResponse response, HttpSession session) { - + public ApiResponse accountSignIn(AccountSignInRequest request, HttpServletResponse response, HttpSession session) { Account account = accountRepository.findAccountByEmail(request.getEmail()); - if (account == null) throw new ApiException(ErrorStatus._ACCOUNT_NOT_FOUND); - if (!account.getPassword().equals(request.getPassword())) throw new ApiException(ErrorStatus._WRONG_PASSWORD); + if (account == null) { + return ApiResponse.onCustomSuccessData("ACCOUNT404", "계정을 찾을 수 없습니다.", null); // isSuccess: true + } + if (!account.getPassword().equals(request.getPassword())) { + return ApiResponse.onCustomSuccessData("ACCOUNT400", "비밀번호가 일치하지 않습니다.", null); // isSuccess: true + } // AccessToken 발급 및 응답 헤더에 추가 String accessToken = jwtProvider.generateAccessToken(account); @@ -123,8 +126,7 @@ public String accountSignIn(AccountSignInRequest request, HttpServletResponse re // RefreshToken 발급 및 세션에 저장 jwtProvider.storeRefreshTokenInSession(account, session); - return "로그인 성공"; - + return ApiResponse.onSuccessData("로그인 성공", accessToken); } @Override diff --git a/src/main/java/the_monitor/common/ApiResponse.java b/src/main/java/the_monitor/common/ApiResponse.java index 190a58b..617da4e 100644 --- a/src/main/java/the_monitor/common/ApiResponse.java +++ b/src/main/java/the_monitor/common/ApiResponse.java @@ -47,6 +47,10 @@ public static ApiResponse of(BaseCode code, T result) { } + public static ApiResponse onCustomSuccessData(String code, String message, T result) { + return new ApiResponse<>(true, code, message, result); + } + public static ApiResponse onSuccess(String message) { return new ApiResponse<>(true, SuccessStatus._OK.getCode(), @@ -68,4 +72,6 @@ public static ApiResponse onFailure(String code, String message, T data) } + + } \ No newline at end of file diff --git a/src/main/java/the_monitor/common/Config/WebConfig.java b/src/main/java/the_monitor/common/Config/WebConfig.java index a52afb3..d7b12ab 100644 --- a/src/main/java/the_monitor/common/Config/WebConfig.java +++ b/src/main/java/the_monitor/common/Config/WebConfig.java @@ -23,6 +23,7 @@ public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("https://the-monitor.o-r.kr", "http://the-monitor.o-r.kr", + "https://the-monitor.vercel.app/", "http://localhost:5173", "http://localhost:8080") .allowedMethods("*") diff --git a/src/main/java/the_monitor/presentation/AccountController.java b/src/main/java/the_monitor/presentation/AccountController.java index 00b6a12..d453c3f 100644 --- a/src/main/java/the_monitor/presentation/AccountController.java +++ b/src/main/java/the_monitor/presentation/AccountController.java @@ -52,8 +52,7 @@ public ApiResponse createAccount(@RequestBody @Valid AccountSignUpReques @PostMapping("/signIn") public ApiResponse Login(@RequestBody @Valid AccountSignInRequest request, HttpServletResponse response, HttpSession session) { - return ApiResponse.onSuccess(accountService.accountSignIn(request, response, session)); - + return accountService.accountSignIn(request, response, session); } @Operation(summary = "토큰 유효성 검사", description = "토큰 유효성 검사")