Dotnet
Authentication and Authorization - Login

Create Login Endpoint

PRO

I finished! On to the next chapter

Outline

Demo: Create Login Endpoint

In the Conduit.Api Project

Modify the UsersController.cs file
  • Create a new public method called Login
  • Returns an IActionResult
  • Recieves a parameter from the body of the request called UserRequest with a generic type Login
In the body of the Login Method
  • Call the non-existing method on the IAccountRepository named LoginAsync
  • Include the await keyword to make the method call async
  • Pass in req.User as a parameter
  • return an ok response along with the user object
Using Visual Studio's IDE Tools

Fix all errors by using [Show Potential Fixes]

Hint: Review the RegisterUserAsync method to help implement the LoginAsync method.