I am building a jhipster application. and I am trying to get a list of objects based on the current logged in user. there are a few simple examples online such as jhipster b
Currently the best answer is to use built-in UserService - the one provided by JHipster. You don't have to repeat calling SecurityUtils.getCurrentUserLogin() twice (once yourself and once in UserService - check implementation). Usage would look like this:
final Optional isUser = userService.getUserWithAuthorities();
if(!isUser.isPresent()) {
log.error("User is not logged in");
return new Shinything()
}
final User user = isUser.get();
// continue with the user