Chapter 8: Guarding Routes and Testing Authentication
In the previous chapter, we saw how to use Apollo Client to send queries and mutations to our previously implemented backend API. We integrated Apollo with our Angular frontend, then implemented the required services and components for user authentication.
We also added functionality to our application header to allow users to navigate between pages such as the profile, home feed, and login pages. We added the necessary functionality to allow users to search for other users on the network using a search bar in the header.
In this chapter, we will continue implementing our auth system by guarding the necessary route(s) against unauthorized access, sending the JWT with the API requests, and unit testing our code.
We will cover the following topics in this chapter:
- Guarding routes
- Testing the auth service and component(s)