hadrihl / user-module-springboot

0 stars 0 forks source link

Hide manage users link on navbar to admin only #1

Closed hadrihl closed 1 year ago

hadrihl commented 2 years ago

as stated. David is a normal type of user. He is supposed not able to see the admin feature (managing user). Only admin type of user should be able to view and click.

demo

hadrihl commented 1 year ago

Dependency issue on pom.xml

<dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>5.7.5</version>
        </dependency>
hadrihl commented 1 year ago

After implementation.

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authorize access="hasAuthority('ADMIN')">
                                <li><a class="dropdown-item" href="/users">
                                    <i class="fa-solid fa-table-columns"></i>
                                    Manage Users</a>
                                </li>
                                </sec:authorize>

demo

Clone/Download the repo and run in Eclipse to see how it works.

hadrihl commented 1 year ago

issue resolved. refer https://github.com/hadrihl/user-module-springboot/commit/efa390dd2777b744fe940721977137de4d98ef82. closing now.