Jhipster AngularJs2 Show Entities Based On ROLE_USER

How To Hide The Jhipster Entities Based On User roles ,For example some entities are not required to show normal users .That means we want to hide that particular entity when ever user logged in and his role is normal user ( ROLE_USER ) .


Follow the below steps to display or hide the entities based on user roles .

open navbar.component.html page which is present at the below path

\src\main\webapp\app\layouts\navbar\navbar.component.html


add the below condition for example

<ul class="dropdown-menu" ngbDropdownMenu>
<li *jhiHasAnyAuthority="'ROLE_ADMIN'" uiSrefActive="active">
<a class="dropdown-item" routerLink="admin" (click)="collapseNavbar()">
<i class="fa fa-fw fa-asterisk" aria-hidden="true"></i>
<span >Admin</span>
</a>
</li>
<li *jhiHasAnyAuthority="['ROLE_ADMIN', 'ROLE_USER']" uiSrefActive="active">
<a class="dropdown-item" routerLink="camp" (click)="collapseNavbar()">
<i class="fa fa-fw fa-asterisk" aria-hidden="true"></i>
<span >Camp</span>
</a>
</li>
<li *jhiHasAnyAuthority="['ROLE_ADMIN', 'ROLE_DONAR']" uiSrefActive="active">
<a class="dropdown-item" routerLink="donar" (click)="collapseNavbar()">
<i class="fa fa-fw fa-asterisk" aria-hidden="true"></i>
<span >Donar</span>
</a>
</li>
<li *jhiHasAnyAuthority="['ROLE_ADMIN', 'ROLE_RECIPIENT']" uiSrefActive="active">
<a class="dropdown-item" routerLink="recipient" (click)="collapseNavbar()">
<i class="fa fa-fw fa-asterisk" aria-hidden="true"></i>
<span >Recipient</span>
</a>
</li>
<li *jhiHasAnyAuthority="['ROLE_ADMIN', 'ROLE_USER']" uiSrefActive="active">
<a class="dropdown-item" routerLink="request" (click)="collapseNavbar()">
<i class="fa fa-fw fa-asterisk" aria-hidden="true"></i>
<span >Request</span>
</a>
</li>
<li *jhiHasAnyAuthority="'ROLE_ADMIN'" uiSrefActive="active">
<a class="dropdown-item" routerLink="staff" (click)="collapseNavbar()">
<i class="fa fa-fw fa-asterisk" aria-hidden="true"></i>
<span >Staff</span>
</a>
</li>
<!-- jhipster-needle-add-entity-to-menu - JHipster will add entities to the menu here -->
</ul>


0 comments:

Post a Comment