Skip to content

Instantly share code, notes, and snippets.

@balvinder294
Created December 30, 2017 15:47
Show Gist options
  • Save balvinder294/af9dcc465809ceda94777e48545a6022 to your computer and use it in GitHub Desktop.
Save balvinder294/af9dcc465809ceda94777e48545a6022 to your computer and use it in GitHub Desktop.
Use this code to get User details in jhipster
# If you are looking for the current User's infos, the one who's currently connected :
final String userLogin = SecurityUtils.getCurrentUserLogin();
will get you, by definition, the current user login, then :
Optional<User> currentUser = userRepository.findOneByLogin(userLogin);
will get you the entity User linked to the login, from which you can access all information with
currentUser.get().getEmail() for example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment