Skip to content

Commit

Permalink
Merge pull request #144 from The-Monitor-Dev/develop
Browse files Browse the repository at this point in the history
FIX: 프론트 요구사항 수정
  • Loading branch information
JIHYUN2EE authored Nov 26, 2024
2 parents ae5dd64 + 0476d99 commit 6a2dcad
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface AccountService {

String accountSignUp(AccountSignUpRequest request);

String accountSignIn(AccountSignInRequest request, HttpServletResponse response, HttpSession session);
ApiResponse<String> accountSignIn(AccountSignInRequest request, HttpServletResponse response, HttpSession session);

String checkEmail(String email);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,15 @@ public String accountSignUp(AccountSignUpRequest request) {
}

@Override
public String accountSignIn(AccountSignInRequest request, HttpServletResponse response, HttpSession session) {

public ApiResponse<String> 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);
Expand All @@ -123,8 +126,7 @@ public String accountSignIn(AccountSignInRequest request, HttpServletResponse re
// RefreshToken 발급 및 세션에 저장
jwtProvider.storeRefreshTokenInSession(account, session);

return "로그인 성공";

return ApiResponse.onSuccessData("로그인 성공", accessToken);
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/the_monitor/common/ApiResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public static <T> ApiResponse<T> of(BaseCode code, T result) {

}

public static <T> ApiResponse<T> onCustomSuccessData(String code, String message, T result) {
return new ApiResponse<>(true, code, message, result);
}

public static <T> ApiResponse<T> onSuccess(String message) {

return new ApiResponse<>(true, SuccessStatus._OK.getCode(),
Expand All @@ -68,4 +72,6 @@ public static <T> ApiResponse<T> onFailure(String code, String message, T data)

}



}
1 change: 1 addition & 0 deletions src/main/java/the_monitor/common/Config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public ApiResponse<String> createAccount(@RequestBody @Valid AccountSignUpReques
@PostMapping("/signIn")
public ApiResponse<String> 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 = "토큰 유효성 검사")
Expand Down

0 comments on commit 6a2dcad

Please sign in to comment.