July 2019
Intermediate to advanced
416 pages
10h 6m
English
With our authentication in place, we want to ensure that users cannot bypass it just by typing in the URL of the page. We wouldn't have much security set up if users could easily bypass it, especially after we went to all the trouble of providing secure authorization. What we are going to do is put another service in place that the router will use to determine whether it can activate the route. First, we create the service, as follows:
ng g s services/Authorization
The service itself is going to implement the CanActivate interface, which the router will use to determine whether the route can be activated. The constructor for this service simply takes in the router and our OauthAuthorizationService service:
export Read now
Unlock full access