How to add more user's information to the Principal object in Spring?

124 Views Asked by At

I have User entity which implements UserDetails interface and UserService which implements UserDetailsService. I want to add a few information to Principal object when user request for it:

@GetMapping(value = "/getCurrentUserInfo")
public Principal currentUser(Principal principal) {
    return principal;
}

I have to add something like first name, second name, userGroupId etc. How I can do it in Spring?

Should I @Override findByUsername() and then in UserRepository do the query like "SELECT * FROM USER"?

0

There are 0 best solutions below