To get Current user details in jhipster

Home Forums Open Source JHipster Discussion To get Current user details in jhipster

This topic contains 0 replies, has 1 voice, and was last updated by  Balvinder Singh 1 year, 3 months ago.

  • Author
  • #2987

    Balvinder Singh

    Hey there if you want to know how to get user details in Jhipster . Check this

    1. First import UserService in your class

    2. Then declare variable

    Private UserService userService

    3. Initialize in constructor

    class_constructor( UserService userService){
    this.userService = userService;

    4. Then You can access details like this using getter values


    For Id : userService.getUserWithAuthorities().get().getId()
    For Name : userService.getUserWithAuthorities().get().getFirstName()
    For Email : userService.getUserWithAuthorities().get().getEmail()
    For Username(login) : userService.getUserWithAuthorities().get().getlogin()

    This way you can access current logged in user Details.

    You can use these values by setting directly or creating variables:

    String userEmail = userService.getUserWithAuthorities().get().getEmail()

    For any queries comment below….

You must be logged in to reply to this topic.