From the course: Angular: Cloud-Powered Apps with Firebase

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using Angular route guards

Using Angular route guards

From the course: Angular: Cloud-Powered Apps with Firebase

Start my 1-month free trial

Using Angular route guards

- [Instructor] Before wrapping up our work on authentication, we need to address a couple of issues. Let me show you what I mean. I'm going to go ahead and log in. Once I log in, I am redirected to the profile route. Let me grab this URL and copy it, and I'm going to log out. On pasting this URL and navigating to it, you can see that I am able to go to this route. Nothing is displayed because there isn't a current authenticated user. We should prevent the user from being able to go to this route. There's also a second issue. Let me go ahead and log in again. Once logged in, I am able to go to the root route, and you can see the logout button appears. In this scenario, we should redirect the user back to the profile page, and not allow them to visit the root page, which displays the login form. Let's tackle the first issue. The Angular router provides a robust way to prevent users from going to specific routes, by…

Contents