diff --git a/src/main/java/org/cmh/backend/Utils/JwtVerifyAspect.java b/src/main/java/org/cmh/backend/Utils/JwtVerifyAspect.java index 42408c9..26cee34 100644 --- a/src/main/java/org/cmh/backend/Utils/JwtVerifyAspect.java +++ b/src/main/java/org/cmh/backend/Utils/JwtVerifyAspect.java @@ -1,5 +1,6 @@ package org.cmh.backend.Utils; +import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.springframework.stereotype.Component; @@ -7,13 +8,17 @@ import org.springframework.stereotype.Component; @Aspect @Component public class JwtVerifyAspect { - @Before("@annotation(JwtVerify) && args(request,..)") - public void verifyJwtToken(Object request) throws JwtValidationException { - if (request instanceof JwtRequest) { - String token = ((JwtRequest) request).getToken(); - if (!JwtUtil.isTokenValid(token)) { - throw new JwtValidationException("JWT token is invalid"); + @Before("@annotation(JwtVerify)") + public void verifyJwtToken(JoinPoint joinPoint) throws JwtValidationException { + Object[] args = joinPoint.getArgs(); + for (Object arg : args) { + if (arg instanceof JwtRequest jwtRequest) { + String token = jwtRequest.getToken(); + if (!JwtUtil.isTokenValid(token)) { + throw new JwtValidationException("JWT token is invalid"); + } } + break; } } }