I am trying to display a delete button only for the person who post a comment and for the ADMIN, however when I try to hide it using an if statment or sec:authorize there is an error parsing the template. I tried to do two separete buttons using each if condition separately and it worked fine, however when I combine them using OR there is a mistake.
This is what I have wrote so far. // the HTML
<a th:if="${c.email}==${namePrincipal} or hasRole('ADMIN')" href="#" class="btn btn-secondary" style="background-color: #8db8e0; margin-left: 200px;">Delete</a>
The error message: org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/show-comments.html]")
Caused by: org.attoparser.ParseException: Could not parse as expression: "${c.email}==${namePrincipal} or hasRole('ADMIN')" (template: "show-comments" - line 34, col 20)
To give the permission based on roles ,
sec:authorizeis used