Reputation: 937
I have a cookie based authentification system in my app and after auth I'm being able to call my API successfully using this._http.get(this.actionUrl, { withCredentials: true })
But my problem is that I would also want to control the access to my components or route but I have no idea how I could achieve this.
Thank in advance
Upvotes: 3
Views: 4628
Reputation: 19640
What you are looking for are Angular Guards
There are four different guard types we can use to protect our routes:
CanActivate - Decides if a route can be activated
CanActivateChild - Decides if children routes of a route can be activated
CanDeactivate - Decides if a route can be deactivated
CanLoad - Decides if a module can be loaded lazily
A Simple canActivate and canDeactivate guard
Live Example - https://rahulrsingh09.github.io/AngularConcepts/guard
Upvotes: 4