I have a password reset action in my mvc controller with this code:
var user = AuthService.GetUser(command.IdUser);
if (user == null)
return PartialView("_MessageFailed", "The user doesn't exists");
if (user.TenantId != command.IdWebsite)
return PartialView("_MessageFailed", "You are not allowed to reset this user password");
var token = AuthService.GenerateUserPasswordToken(user.Id);
var result = AuthService.ResetPassword(user.Id, token, command.NewPassword);
return PartialView("_MessageSuccess", "The password has changed");
return PartialView("_MessageFailed", string.Join("<br>", result.Errors));
The user exists, but I'm having an error in the result object in reset method that says
Name email@example.com is already taken.
Why is this happening? Could be because in the aspnetusers table in the database are two users with the same email and different tenantId? How can I fix this?