I developed a login system using Web Api 2..... all worked perfectly, but suddenly it stopped working when user enters wrong password at login screen.
When user and password are correct, the token is correctly gotten and user is logged in.
But when user or password is wrong, it is getting a Bad Request response. This worked before, so i don't know what happened.
When debugging, I could see that OAuthAuthorizationServerProvider set the invalid_grant in such a case, in this code:
var userManager = context.OwinContext.GetUserManager<ApplicationUserManager>();
ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password);
if (user == null)
{
context.SetError("invalid_grant", "El nombre de usuario o la contraseña no son correctos.");
return;
}
if (user.Locked)
{
context.SetError("invalid_grant", "El usuario está bloqueado. Contáctese con el administrador.");
return;
}
Unfortunately, I cannot debug further, so I could not know what happens after the "return".
Any idea what is happening?
These are the headers of the response (url is /Token)
Cache-Control
private
Content-Length
4901
Content-Type
text/html; charset=utf-8
Date
Fri, 30 Nov 2018 23:44:15 GMT
Expires
-1
Pragma
no-cache
Server
Microsoft-IIS/10.0
X-Powered-By
ASP.NET
X-SourceFiles
=?UTF-8?B?QzpcV29ya2luZ0ZvbGRl…Edlc3RvckRvY1dlYlxUb2tlbg==?=