Skip to content

Commit

Permalink
fix: 방 조회 if문안으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
yooooonshine committed Aug 12, 2024
1 parent d504e46 commit 50e9224
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
Expand All @@ -20,6 +21,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import middle_point_search.backend.common.exception.CustomException;
import middle_point_search.backend.common.exception.errorCode.UserErrorCode;
import middle_point_search.backend.common.properties.SecurityProperties;
import middle_point_search.backend.common.security.jwt.provider.JwtTokenProvider;
import middle_point_search.backend.domains.member.repository.MemberRepository;
Expand Down Expand Up @@ -59,9 +61,6 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse

final String tokenRoomId = jwtTokenProvider.extractRoomId(accessToken).orElse(null);

Room headerRoom = roomRepository.findByIdentityNumber(headerRoomId)
.orElseThrow(() -> new CustomException(ROOM_NOT_FOUND));

//1. access토큰이 존재하며, accessToken이 유효하면 인증
//2. access토큰이 존재하며, accesToken이 유효하지 않으면 에러 리턴
//3. refresh토큰이 존재하며, refreshToken이 유효하면 access 토큰 재발급
Expand All @@ -76,6 +75,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
}

//헤더 ROOM의 있는 방의 Type과 헤더의 RoomType이 같은지 검사(room검사보다 먼저 되어야 함)
Room headerRoom = roomRepository.findByIdentityNumber(headerRoomId)
.orElseThrow(() -> new CustomException(ROOM_NOT_FOUND));
final RoomType headerRoomType = jwtTokenProvider.extractRoomType(request).orElse(null);
if (headerRoomType != headerRoom.getRoomType()) {
throw new CustomException(ROOM_TYPE_UNPROCESSABLE);
Expand Down

0 comments on commit 50e9224

Please sign in to comment.