Using Route Guards
Guards should only be applied to protected URLs. There should be no guard active on the default route where the authorization request is processed.
Please refer to the auto-login guard in this repo as a reference. It is important that the callback logic can be run on a route without the guard running or run before the guard logic.
To apply the guard for specific routes you have to add it to the route configuration e.g. with canActivate
:
All other guard types like canLoad
or canActivateChild
work in a similar way. However, the guard class has to implement the respective interfaces and methods accordingly.