public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByNameAsync(model.Phone); //var user = await UserManager.FindByNameAsync(model.Email); if (user == null) { // Don't reveal that the user does not exist or is not confirmed return View("ForgotPasswordConfirmation"); } if( (!(await UserManager.IsPhoneNumberConfirmedAsync(user.Id)))) { ViewBag.Message = "Your phone is not confirmed. We have sent you an SMS. Please Reply Back my SMS to number indicated."; ViewBag.Title = "SMS Not Confirmed!"; return View("Error"); } // 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(user.Id); return RedirectToAction("ForgotPasswordConfirmation", "Account"); } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult ForgotPassword(string phone="") { ForgotPasswordViewModel model = new ForgotPasswordViewModel() { Phone = phone }; return View(model); }