Internal server error on ResourceOwner Password Validation
Hello, I'm trying to implement a ResourceOwnerPasswordValidator to retrieve my users from a database. It seems to be working whenever I use the login form from Identity Server, but not when using actual Resource Owner flow through a POST request.
Here's the code for ResourceOwnerPasswordValidator:
public class ResourceOwnerPasswordValidator : IResourceOwnerPasswordValidator
{
private static readonly UnitOfWork _unitOfWork = new UnitOfWork();
public ResourceOwnerPasswordValidator()
{
//_myUserManager = new MyUserManager();
}
public async Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
{
var usersList = GetUsers();
var user = usersList.Where(u => u.Username == context.UserName).FirstOrDefault();
if (user != null && user.Password == context.Password)
{
context.Result = new GrantValidationResult(
subject: user.Subject,
authenticationMethod: "custom",
claims: user.Claims);
return;
}
context.Result = new GrantValidationResult(
TokenRequestErrors.InvalidGrant,
"invalid custom credential");
}
}
I put a breakpoint in the Login action, but it never gets hit when using a POST request. On the
return; line, it seems that the context result is correct, but it return a 500 response when sent.
..and you have registered the validator and use the token endpoint? logs?
Nevermind, turns out it was an issue with conflicting Subjects on my user store, since I don't have a singe Users table.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.