public async Task <IActionResult> ForgotPassword(ForgotPassViewModel vm) { if (vm.Email.Contains("aol.com") || vm.Email.Contains("amail.com")) { ModelState.AddModelError("", "We don't support this email domain addresses "); } var user = await _userManager.FindByEmailAsync(vm.Email); if (user == null /*|| !(await _userManager.IsEmailConfirmedAsync(user))*/) { ModelState.AddModelError("Email", "This email does not registered!"); } if (ModelState.IsValid) { var codes = await _userManager.GeneratePasswordResetTokenAsync(user); var callbackUrl = Url.Action(nameof(SignupController.ResetPassword), "Signup", new { userId = user.Id, code = codes }, protocol: HttpContext.Request.Scheme); await _mailService.ConfirmationByEmailMsgAsync(vm.Email, "Reset Password", $"Click - <a href='{callbackUrl}'>HERE</a> - to reset your password"); } return(View(nameof(ForgotPasswordConfirmation))); }
public async Task <IActionResult> ForgotPassword(ForgotPassViewModel forgotModel) { if (!ModelState.IsValid) { return(View(forgotModel)); } var user = new User(); string userEmail = FixedText.FixedEmail(forgotModel.Email); if ((user = await _UserService.ForgotPassword(userEmail)) == null) { ModelState.AddModelError("Email", "ایمیل وارد شده یافت نشد"); return(View(forgotModel)); } else { string bodyEmail = _renderViewService.RenderToStringAsync("_ForgotPassword", user); SendEmail.Send(userEmail, "ایمیل تایید فراموشی رمز عبور", bodyEmail); ViewBag.IsSuccess = true; return(View()); // return View("ChangePassEmailConfirmation", model: user); } }
public ForgotPassword() { InitializeComponent(); BindingContext = new ForgotPassViewModel(); }