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.
Update the header for logout functionality
From the course: Building Angular and ASP.NET Web API Apps
Update the header for logout functionality
- [Instructor] In this part you learn how to dynamically update the header here at the top right based on the user status. So if the user is logged in, then we want to show the add transaction and the logout button, and if the user is logged out, then we want to show the login button. For that we need to first update the authentication service and here at the top I'm going to use a behavior subject to manage the current user state. This allows us to track whether a user is logged in or not and just share the state across different parts of the app. We're going to just define that here at the top. So just after the private api endpoint, I'm going to type private currentUserSubject = new BehaviorSubject. So this way we can basically track user state and then just share this state across different parts of the app. So BehaviorSubject, this is going to be string or null. The default value is going to be null. And then we're going to use this currentUser, which is an observable, and this…
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
-
-
-