spring security中获取当前登录用户

2022-03-14  本文已影响0人  莫名ypc

spring security中获取当前登录用户

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (!(authentication instanceof AnonymousAuthenticationToken)) {
    String currentUserName = authentication.getName();
    return currentUserName;
}
上一篇下一篇

猜你喜欢

热点阅读