I use spring boot 2 and spring security.
With aop, I search to get user who called the method.
@Aspect
@Component
public class LogAspect {
@Before("execution(* com.moplogy.controller.*))")
public void getAllAdvice(JoinPoint joinPoint){
System.out.println("method called " + joinPoint.getSignature().getName());
}
}
any idea?
try to add in you method this line
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With