From the course: Building Angular and ASP.NET Web API Apps
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Logging in users
From the course: Building Angular and ASP.NET Web API Apps
Logging in users
- [Instructor] Now that we have built the login component we will implement the login mechanism. For that, we are going to first complete the login method in our Web API project, then we are going to see how to call the Web API endpoint from Angular application. And then next we are going to learn how to handle errors in Angular. And finally, will store the response in the localStorage. In the AuthenticationController.cs file, scroll down to the login method. And in here, let us first check if the user model has all the necessary data. So for that, let us write if, then string.IsNullOrEmpty. We check first for the UserName, so user.UserName, or string.IsNullOrEmpty user.Password. So if any of them IsNullOrEmpty, then we want to return a response BadRequest. And as a message, we want to write in here, Enter your username and password. If the user has already provided the username and the password, let us check if this user actually exists in our database. So for that, we first open a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Setting up AuthController5m 10s
-
(Locked)
Setting up AuthService3m 8s
-
(Locked)
Creating a register component5m 6s
-
(Locked)
Registering users6m 18s
-
(Locked)
Generating a token6m 53s
-
(Locked)
Requesting a token from Angular4m 42s
-
(Locked)
Authentication check via tokens5m 11s
-
(Locked)
Logging out users1m 54s
-
(Locked)
Creating an Angular login component4m 47s
-
(Locked)
Getting data from the login form4m 25s
-
(Locked)
Logging in users4m 20s
-
(Locked)
Handling errors in angular4m 2s
-
(Locked)
-
-