A common recommended way to secure Angular 2 component/routes seems to be to use @CanActivate()
, like here:
http://youknowriad.github.io/angular2-cookbooks/stateless-authentication.html
If you have only a few components this works fine, but is there a better way that would centralize all this?
Would having a common base class for each component work? (any examples on how to do this?). Could we have a custom @CanActivate()
, something like @ProtectMyApp()
? (examples?)
I'm basically trying to prevent having to copy+paste the same @CanActivate()
code for each component.
(apologies if these questions do not make sense, still learning Angular)
Thanks