private static final Logger LOGGER = LoggerFactory.getLogger(SecurityUtil.class);
public static void logInUser(User user) {
LOGGER.info("Logging in user: {}", user);
ExampleUserDetails userDetails = ExampleUserDetails.getBuilder()
.firstName(user.getFirstName())
.id(user.getId())
.lastName(user.getLastName())
.password(user.getPassword())
.role(user.getRole())
.socialSignInProvider(user.getSignInProvider())
.username(user.getEmail())
.build();
LOGGER.debug("Logging in principal: {}", userDetails);
Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
LOGGER.info("User: {} has been logged in.", userDetails);
}