I am attempting to allow password reset for my users and I cannot figure out why code and callbackUrl are returning false. Here is my forgot password method:
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
{
if (ModelState.IsValid)
{
var user = await UserManager.FindByNameAsync(model.Email);
if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
{
// Don't reveal that the user does not exist or is not confirmed
return View("ForgotPasswordConfirmation");
}
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
// Send an email with this link
string callbackUrl = await ResetPasswordConfirmationTokenAsync(user.Id, "Password Reset");
return RedirectToAction("ForgotPasswordConfirmation", "Account");
}
// If we got this far, something failed, redisplay form
return View(model);
}
then I create the password reset task
private async Task<string> ResetPasswordConfirmationTokenAsync(string userID, string subject)
{
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
// Send an email with this link:
string code = await UserManager.GeneratePasswordResetTokenAsync(userID);
var callbackUrl = Url.Action("ForgotPassword", "Account", new { userId = userID, code = code }, protocol: Request.Url.Scheme);
await UserManager.SendEmailAsync(userID, subject, "Please confirm your account by <a href=\"" + callbackUrl + "\">clicking here</a>");
return callbackUrl;
}
Since both values return null it generates the error No IUserTokenProvider is registered. Why is this happening when user is not null?

