Angular Features
We have implemented configurable features to make using the Angular component of Skulljs as easy as possible.
Angular Documentation
For more information check the official documentation.
Official Angular Documentation →
IsAuthorized Guard
To simplify access management of Angular routes, Skulljs comes equipped with a built-in guard named IsAuthorized
.
The guard comes with two modes:
- Minimun Role Mode: check if the user have the listed role or a superior one
- List Role Mode: check if the user have one of the listed roles
You can switch the mode with the minimunRoleMode boolean.
Roles description
You can add or remove any roles in the file detailed below.
// frontend/src/app/guards/isAuthorized/roles.ts
export enum Roles {
NonLoggedUser = 0,
LoggedUser = 10,
Admin = 80,
// example
MyRole = 20,
}
Usage
// any routing module
import { isAuthorizedGuard } from "./guards/IsAuthorized/is-authorized.guard";
import { Roles } from "./guards/IsAuthorized/roles";
const routes: Routes = [
{
path: 'admin',
component: AdminComponent,
canActivate: [isAuthorizedGuard],
data: {
authorize: [Roles.Admin],
minimunRoleMode: true,
// Redirection url if the user isn't allowed to access the route
fallbackRoute: '/auth',
},
},
];