• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

장바구니 컨트롤러 처리 @PreAuthorize 부분 오류

24.04.15 22:47 작성 조회수 81

0

@PreAuthorize("(#itemDTO.email == authentication.name)")
@PostMapping("/change")
public List<CartItemListDTO> changeCart(@RequestBody(required = true) CartItemDTO itemDTO) {
    log.info("itemDTO : {}", itemDTO);
    if (itemDTO.getQuantity() <= 0) {
        return cartService.remove(itemDTO.getCino());
    }
    return cartService.addOrModify(itemDTO);
}

위코드에서 #ItemDTo 값이 null 설정되는것같습니다.

아무리 찿아봐도 원일을 알수없는데 확인좀 부탁드릴수 있을까요?

 

우선 오류로그는 아래와 같습니다.

jakarta.servlet.ServletException: Request processing failed: java.lang.IllegalArgumentException: Failed to evaluate expression '(#itemDTO.email == authentication.name)'

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1022) ~[spring-webmvc-6.1.5.jar:6.1.5]

at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914) ~[spring-webmvc-6.1.5.jar:6.1.5]

 

Caused by: java.lang.IllegalArgumentException: Failed to evaluate expression '(#itemDTO.email == authentication.name)'

 

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'email' cannot be found on null

at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224) ~[spring-expression-6.1.5.jar:6.1.5]

at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:111) ~[spring-expression-6.1.5.jar:6.1.5]

at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorValueRef.getValue(PropertyOrFieldReference.java:416) ~[spring-expression-6.1.5.jar:6.1.5]

at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:98) ~[spring-expression-6.1.5.jar:6.1.5]

at org.springframework.expression.spel.ast.OpEQ.getValueInternal(OpEQ.java:42) ~[spring-expression-6.1.5.jar:6.1.5]

at org.springframework.expression.spel.ast.OpEQ.getValueInternal(OpEQ.java:32) ~[spring-expression-6.1.5.jar:6.1.5]

at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:119) ~[spring-expression-6.1.5.jar:6.1.5]

at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:309) ~[spring-expression-6.1.5.jar:6.1.5]

at org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:30) ~[spring-security-core-6.2.3.jar:6.2.3]

 

 

 

 

답변 2

·

답변을 작성해보세요.

1

일단 해결이 되셨다니 다행입니다..

 

3.2.4버전을 다시 한번 체크해 보겠습니다.

1

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'email' cannot be found on null

 

부분에서 문제가 생기고 있는 거 같습니다.

https://drive.google.com/drive/folders/1ZLHRKaXx8Ou8kZNd1WE6qALxq_wJODXW?usp=drive_link

 

폴더를 잠시 열어 두었으니 코드를 올려주세요.. (프론트 코드도 있는게 좋을 듯 한데요)

 

제가 오늘 밤에는 좀 일이 있어서.. 늦어도 내일 오전에 댓글 남기겠습니다.

부트쪽 코드 버전 확인 부탁드립니다.

 

CartController 관련 부분이 없는 거 같습니다.

박정식님의 프로필

박정식

질문자

2024.04.15

 

말씀하시데로 스프링부트 3.2.4 에서 3.1.9 로 내리니까 정상적으로 작동합니다.

좋은 밤 보내세요.

감사합니다.