diff --git a/src/main/java/app/annotations/impl/PermitionFlagAspect.java b/src/main/java/app/annotations/impl/PermitionFlagAspect.java index e7ca472..dcbaa96 100644 --- a/src/main/java/app/annotations/impl/PermitionFlagAspect.java +++ b/src/main/java/app/annotations/impl/PermitionFlagAspect.java @@ -3,11 +3,16 @@ package app.annotations.impl; import app.annotations.exceptions.InvalidCookie; import app.annotations.exceptions.LowPermition; import app.annotations.exceptions.NeedCookie; +import app.annotations.interfaces.CheckPermitionFlag; import app.entities.db.Permition; import app.services.ProfileService; import jakarta.servlet.http.HttpServletRequest; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.reflect.MethodSignature; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; @@ -30,8 +35,9 @@ public class PermitionFlagAspect { return permition.getFlags().contains(flag); } - @Before("@annotation(app.annotations.interfaces.CheckPermitionFlag) && args(request,..)") - public void before(HttpServletRequest request){ + @Before(value = "@annotation(app.annotations.interfaces.CheckPermitionFlag) && args(request,..)") + public void before(JoinPoint joinPoint, HttpServletRequest request){ + String flag = ((MethodSignature) joinPoint.getSignature()).getMethod().getAnnotation(CheckPermitionFlag.class).flag(); System.out.println("check permition flag"); if(!(request instanceof HttpServletRequest)) { throw new RuntimeException("invalid request"); @@ -50,7 +56,7 @@ public class PermitionFlagAspect { throw new InvalidCookie(); } - if(!ValidateAdmin(steam64, "z")){ + if(!ValidateAdmin(steam64, flag)){ throw new LowPermition(); } }