-
Notifications
You must be signed in to change notification settings - Fork 10
Permissions
Permissions are the way to control the access to the resources of the system. It's a way to ensure that only the authorized users can access the resources they need.
There are two types of permissions: Frontend and Backend.
Frontend permissions are the permissions that are controlled by the frontend. They are used to control the access to the frontend resources, like pages, buttons, etc.
We use package ngx-permissions
to manage frontend permissions. This package helps you gain control of your routes, by using simple concepts for you to decide who can access them.
import { NgxPermissionsGuard } from 'ngx-permissions';
const appRoutes: Routes = [
{ path: 'home',
component: HomeComponent,
canActivate: [NgxPermissionsGuard],
data: {
permissions: {
only: ['ADMIN', 'MODERATOR'],
except: ['GUEST']
}
}
},
];
You can access mgx-permission's wiki page to see more details.
You can also control element in the template using *ngxPermissionsOnly
directive.
<div *ngxPermissionsOnly="['ADMIN', 'GUEST']">
<div>You can see this text congrats</div>
</div>
Backend permissions are the permissions that are controlled by the backend. They are used to control the access to the backend resources, like APIs, databases, etc.
todo