Our previous routing example worked very well, but in some applications, you might need authorization so that only logged-in users may access parts of your website. (You would also need the user to be identified, if you were using an API such as the one we developed in Chapter 4, Implementing RESTful Services with Node, which required JSON Web Token (JWT). So, let's see what extra work we need in order to have both restricted and unrestricted routes on our page.
Adding authorization to routes
How to do it...
Let's add authorization to our application by protecting some routes and requiring a previous successful login.
We can find a very React-like solution. We will have some unprotected routes that anybody may access...