Issue
I use Spring Boot, Spring Boot Security, thymeleaf-extras-springsecurity5. I want get information about current user and write:
<div sec:authorize="isAuthenticated()">
Authenticated as <span sec:authentication="name"></span></div>
and get All User information Like that:
Authenticated as User(id=7, firstName=TOGRUL, lastName=Mamedov, patronymic=dddddd, [email protected], phone=+99477777777, password=$2a$11$txs/zdaLq.6eeBHz3uyM0e/R6uzJHs2.UIeIeRrV906y6Ia/hMOE6, enabled=true, secret=MVNSUPKHWTAVLIEQ, country=Azerbaijan, state=Baki, city=Badamdar, gender=Man, addressLine=GANJA, zipCode=2001, birthDay=01-07-2020, passportSeria=AZE, passportNumber=1234567, finCode=1234567, avatar=/resources/images/user-icon.png, mytext=null, active=0, isUsing2FA=false, roles=[Role [name=ROLE_USER][id=5]])
For base authentication I use this project. https://github.com/Baeldung/spring-security-registration
How to fix this error if it is a bug? I think password should't be shown anyway. How get username? How get other information if it possible? It is look like Array or some.property
Solution
I see you are using thymeleaf. Try this expression and instead of "getSomeProperty()" call any get method of your user class
${#authentication.getPrincipal().getSomeProperty()}
Answered By - 3asyPe
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)