So I'm building an api using asp.net 5 MVC 6, and I followed the Microsoft tutorial on building new web APIs to get started. I then followed the answers to this question to implement JWT token based authentication, but I am stuck here:
if ((req.username == "TEST" && req.password == "TEST") || (req.username == "TEST2" && req.password == "TEST"))
{
DateTime? expires = DateTime.UtcNow.AddMinutes(2);
var token = GetToken(req.username, expires);
return new { authenticated = true, entityId = 1, token = token, tokenExpires = expires };
}
Instead of this if
statement I need to somehow call the UserManager
class and check if the username and password actually matches a user in my database, as I do in my old MVC 5 API with:
ApplicationUser user = await _userManager.FindAsync(userName, password);
I believe I am actually missing some implementation of the UserManager
.
I am working off an existing database that already has users created using Identity 2.0. My knowledge of ASP.NET 5 is limited, so I have just been following various guides and tutorials.