...

/

Protected Routes in React with Authorization

Protected Routes in React with Authorization

In this lesson, we will learn how to put restrictions on access to certain pages based on the user's privileges.

So far, all the routes of our application are accessible to everyone whether the user is authenticated or not.

For instance, when we sign out on the home or account page, there is no redirection, even though these pages should only be accessible to authenticated users. There is no reason to show a non-authenticated user the account or home page because these are the places where a user accesses sensitive information.

Route Protections

In this section, we will implement the protection for these routes called authorization. The protection is a broad-grained authorization, which checks for authenticated users. If none are present, it ...