Event Guard
Let's create our second route guard to restrict the "/update" URL to the event creator.
We'll cover the following
We finished the last chapter by noting an error with our event update page. That error allows any authorized user to update an event simply by appending /update
to /event/{id}
.
In this chapter, we’ll create another route guard, similar to AuthGuard
, that restricts users from viewing the /update
page for an event unless they are the creator of that event.
Create EventGuard
First, we’ll create our new route guard. Similar to the AuthGuard
we created in the chapter,Auth Guard, we’ll select the CanActivate
interface, which should be the default option.
ng g guard guards/event/event
Get hands-on with 1400+ tech skills courses.