From the course: Building Angular and ASP.NET Web API Apps
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Secure routes with Angular Guards
From the course: Building Angular and ASP.NET Web API Apps
Secure routes with Angular Guards
- [Instructor] In this part, you learn how to create and how to use an AuthGuard. In Angular, AuthGuard is a feature used to protect routes from unauthorized access. This way you ensure that certain parts of your app are only accessible to users who do meet certain conditions. Now, conditions for the users can be as simple as just to check if the user is authenticated or not, but you can also have more complex conditions, like for example, to check if the user has a certain role, they have a certain claim, and much more. To better understand this concept, let us go to our project. Now in here in this project, you can either use the Angular CLI, and for that, you just type ng generate guard, and then just provide the guard name. Or you can just create a folder manually, just type guards. Then right click in here, add a file. The file is going to be auth.guard.ts. Then inside here, we are just going to create a constant, export const authGuard. This will not take any parameters. And…
Contents
-
-
-
-
-
-
Understanding token-based authentication3m 2s
-
(Locked)
Configure token-based authentication in ASP.NET Web API5m 49s
-
(Locked)
Build the register API endpoint11m 29s
-
(Locked)
Create the login API endpoint9m 47s
-
(Locked)
Develop the authentication service in angular8m 7s
-
(Locked)
Register for a new account15m 38s
-
(Locked)
Add data validation to a registered form11m 28s
-
(Locked)
Log in to an account6m 6s
-
(Locked)
Secure routes with Angular Guards5m 54s
-
(Locked)
Update the header for logout functionality6m 53s
-
(Locked)
Implement the auth interceptor7m 21s
-
(Locked)
Set a user ID when a transaction is created and loaded8m 28s
-
-
-