public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
var result = await SignInManager.PasswordSignInAsync(context.UserName, context.Password, false, false);
switch (result)
{
case SignInStatus.Success:
var identity = new ClaimsIdentity(context.Options.AuthenticationType);
identity.AddClaim(new Claim("sub", context.UserName));
identity.AddClaim(new Claim("role", "user"));
context.Validated(identity); break;
default:
context.SetError("Authorization error", "The username of password is incorrect");
//context.Rejected();
break;
}
}