public async Task <IActionResult> forgotpassword(forgotpasswordViewModel model) { if (ModelState.IsValid) { var user = await userManager.FindByEmailAsync(model.Email); if (user != null) { var token = await userManager.GeneratePasswordResetTokenAsync(user); var passwordresetlink = Url.Action("resetPassword", "Account", new { email = model.Email, token = token }, Request.Scheme); UserEmail userEmail = new UserEmail { ToEmail = model.Email, }; var arr = new List <KeyValuePair <string, string> >(); var temp = new KeyValuePair <string, string>("{{passwordlink}}", passwordresetlink); //temp.Key = "username"; //temp.Value = "*****@*****.**"; arr.Add(temp); userEmail.PlaceHolder = arr; await emailService.ForgotpasswordEmail(userEmail); ViewBag.msg = "We send Password reset link To your account"; return(View()); } ModelState.AddModelError(string.Empty, "Your Account is not found"); return(View()); } return(View()); }
public async Task <ActionResult> forgotemail(forgotpasswordViewModel model) { var res = await forgotpassword(model.email); if (!res.Succeeded) { return(RedirectToAction("login")); } else { return(RedirectToAction("login", "user", new { @forgotpassword = res.ToString() })); } }