응답 처리 변경

This commit is contained in:
nevermoregb 2025-03-13 10:37:16 +09:00
parent f52b5be47c
commit c277eb1a27

View File

@ -49,6 +49,7 @@ import io.company.localhost.common.dto.ApiResponse;
import io.company.localhost.common.dto.MapDto;
import io.company.localhost.common.exception.InvalidPasswordException;
import io.company.localhost.common.exception.NotFoundHandler;
import io.company.localhost.common.exception.code.UserErrorCode;
import io.company.localhost.service.commoncodService;
import io.company.localhost.service.localbordService;
import io.company.localhost.utils.AuthUtil;
@ -329,11 +330,13 @@ public class BoardController {
String storedHashedPassword = boardService.selectBoardPassword(boardId);
if (storedHashedPassword == null) {
throw new NotFoundHandler("해당 게시물이 존재하지 않습니다.");
}
boolean isMatch = passwordEncoder.matches(rawPassword, storedHashedPassword);
if (!isMatch) {
throw new InvalidPasswordException("비밀번호가 일치하지 않습니다.");
//throw new InvalidPasswordException("비밀번호가 일치하지 않습니다.");
return ApiResponse.error(HttpStatus.UNAUTHORIZED, "비밀번호가 일치하지 않습니다.");
}
return ApiResponse.ok(true);
@ -366,7 +369,8 @@ public class BoardController {
boolean isMatch = passwordEncoder.matches(rawPassword, storedHashedPassword);
if (!isMatch) {
throw new InvalidPasswordException("비밀번호가 일치하지 않습니다.");
//throw new InvalidPasswordException("비밀번호가 일치하지 않습니다.");
return ApiResponse.error(HttpStatus.UNAUTHORIZED, "비밀번호가 일치하지 않습니다.");
}
return ApiResponse.ok(true);