The TokenController

The next step will be to add a TokenController to issue and refresh tokens. Ideally speaking, it will be a good idea to inherit it from the BaseApiController base class we put together back in Chapter 5, Client-Server Interactions, so we can access our ApplicationDbContext. However, we will definitely need even more than that; since we'll be working with users, it would be nice to also have an (injected) instance of that UserManager class we did use when working on our DbSeeder class. On top of that, we'll definitely need to access the JWT configuration values we put in the AppSettings files a moment ago.

In order to have access to all these objects, we can choose between three possible approaches:

  1. Inject all this stuff ...

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.