code: public User getLoggedInUser() {
      User user = null;
  
      final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
      if (authentication != null) {
        final Object principal = authentication.getPrincipal();
  
        // principal can be "anonymousUser" (String)
        if (principal instanceof UserDetails) {
          user = userDetailsConverter.convert((UserDetails) principal);
        }
      }
      return user;
    }
docs: get logged in user.
  
  @return UserData or null if no one is logged in