Skip to content

An angular guard that chains other guards, waiting for each one to complete before proceeding to the next.

License

Notifications You must be signed in to change notification settings

mrahhal/ngx-chain-guards

Repository files navigation

ngx-chain-guards

CI npm License

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.

Usage

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.

About

An angular guard that chains other guards, waiting for each one to complete before proceeding to the next.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published