I am trying to display the details of the current user however I keep getting errors. I tried accessing the authenticated user from the template but that did not work as I w
The problem is here:
return new
org.springframework.security.core.userdetails.User(user.getEmailAddress(),
user.getPassword(),
mapRolesToAuthorities(user.getRoles()));
You lose the reference to your User
entity. Change it to:
return user;
For this to work, you need to update your User
entity to implement UserDetails interface:
public class User implements UserDetails {
// some new methods to implement
}
Then, your Thymleaf code should work. Another way of getting the firstName
would be: