An angular guard that chains other guards, waiting for each one to complete before proceeding to the next.
Can be used with canActivate
, canActivateChild
, canDeactivate
.
import { ChainGuards } from 'ngx-chain-guards';
// In the route config:
{
path: '...',
data: {
// The guards you want to chain:
guards: [SomeGuard1, SomeGuard2, ...]
},
canActivate: [ChainGuards],
// or
// canDeactivate: [ChainGuards],
// canActivateChild: [ChainGuards],
}
If you have different guards you want to chain for different methods:
import { ChainGuards } from 'ngx-chain-guards';
// In the route config:
{
path: '...',
data: {
canActivateGuards: [SomeGuard1, SomeGuard2, ...],
canDeactivateGuards: [AnotherGuard, ...]
},
canActivate: [ChainGuards],
canDeactivate: [ChainGuards],
}
Note that you can still specify a guards
array in the above snippet, in which case these will be considered common for all methods, and will be inserted at 0 in the chain before the specific guards.