From the course: Building and Securing RESTful APIs in ASP.NET Core
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Create a registration route - ASP.NET Core Tutorial
From the course: Building and Securing RESTful APIs in ASP.NET Core
Create a registration route
- [Instructor] Let's make it possible for a user to register for the API by simply posting a form to the user's endpoint. I've added a form model called Registerform to the model's folder. You can find it in the exercise files This registration form takes an email, a password, and the user's first and last names. We'll let ASP.NET Core validate these parameters for us, and then create a new user in the system with these values. We need to add a method to the user service to save that user to the database. I'll start in the interface Iuserservice. I'll say Task Create/UserAsync which takes a register form. We can take advantage of a cool feature in C# 7, and return a named tuple here. So this will be a task of parens, bool succeeded, string error message. If you aren't using C# 7 in your project, you could just a simple class to hold these values instead. Now over in the default user service, I'll implement that method as a stub, and make this async. Bring this down here. There we go…
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)
How HTTP authentication works3m 39s
-
(Locked)
Authentication for REST APIs3m 21s
-
(Locked)
Add Identity4m 51s
-
(Locked)
Add a test user3m 21s
-
(Locked)
Create a users collection5m 45s
-
(Locked)
Create a registration route6m 9s
-
(Locked)
Add OpenIddict4m 12s
-
(Locked)
Add a token endpoint2m 6s
-
(Locked)
Create a UserInfo route5m 28s
-
(Locked)
More about OpenID Connect2m 59s
-
(Locked)
Authorization using policies5m 19s
-
(Locked)
-