How to handle user information after login succeed in Spring Security

How to handle user information after login succeed in Spring Security

I want to use user-information after login succeed. I thought about storing it into session attribute. or using @scope('session) annotation. but I haven't found the best way of doing it. so I just stored it into model-attribute.

I want to use user-information after login succeed. I thought about storing it into session attribute. or using @scope('session) annotation. but I haven't found the best way of doing it. so I just stored it into model-attribute.

@Controller
@RequestMapping(value = "/user")
public class UserController {

@Autowired
private UserService userService;

@Autowired
private UserProfileService userProfileService;

@ModelAttribute("user") 
public User getUserModel () {

    return userService.findByEmail(SecurityContextHolder.getContext().getAuthentication().getName());
}

@ModelAttribute("userProfile")
public UserProfile getUserProfile() {

    return userProfileService.findByUser(userService.findByEmail(SecurityContextHolder.getContext().getAuthentication().getName()));
}

@GetMapping("/")
public String userIndex() { 

    logger.info("UserIndex");
    return "userPage";
}

As you can see, SecurityContextHolder.getContext().getAuthentication().getName() --> this method repeated. every time user make HTTP request, is this good practice? or any better way of store user-infomation in application?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Spring Boot Tutorials - Spring Boot Full Course

Spring Boot Tutorials | Full Course - What is Spring? Spring Boot is an open source Java-based framework used to create a Micro Service. Spring Boot contains a comprehensive infrastructure support for developing a micro service and enables you to develop enterprise-ready applications that you can “just run”.

Java Spring - Limiting Query Result with Spring Data JPA

Java Spring - Limiting Query Result with Spring Data JPA

Full-stack Reactive Java with Spring Framework, Spring Boot and Project Reactor

Reactive programming offers Java developers a way to build message-driven, elastic, resilient, and responsive services...yet many Java developers don't know where to begin.