public ActionResult ForgotPassword(ForgotPasswordView view) { if (ModelState.IsValid) { MembershipUser mu = Membership.GetUser(view.UserName); if (mu != null) { try { string newPassword = mu.ResetPassword(view.Answer); PasswordEmailData ped = new PasswordEmailData(); ped.UserName = mu.UserName; ped.NewPassword = newPassword; messageSender.SendWithTemplate("forgotpassword", null, ped, mu.Email); TempData["Errors"] = "Your new password has been sent by email, please check your inbox."; return(RedirectToAction("ForgotPassword")); } catch (MembershipPasswordException) { ModelState.AddModelError("Answer", "Your answer does not match with our records."); } } else { ModelState.AddModelError("UserName", "Your user name is not valid."); } } return(View(view)); }
private void BtnForgot_Click(object sender, RoutedEventArgs e) { ForgotPasswordView forgotPassword = new ForgotPasswordView(); forgotPassword.Show(); Close(); }
private static ForgotPasswordView SqlReaderForgotPassword(SqlDataReader reader) { var model = new ForgotPasswordView(); model.Id = Convert.ToInt32(reader.GetValue(0)); model.Email = Convert.ToString(reader.GetValue(1)); model.UserName = Convert.ToString(reader.GetValue(2)); model.Sex = Convert.ToString(reader.GetValue(3)); model.Nick = Convert.ToString(reader.GetValue(4)); model.Tel = Convert.ToString(reader.GetValue(5)); model.Status = Convert.ToInt32(reader.GetValue(6)); model.Date = Convert.ToDateTime(reader.GetValue(7)); return(model); }
public async Task ForgotPassword(ForgotPasswordView model) { var user = await _userService.FindByNameAsync(model.UserName); var token = await _userService.PasswordResetTokenAsync(user.Id); var clientPath = new Uri(new Uri(_clientOptions.BaseUrl), _clientOptions.ResetPasswordPath); var resetUrl = QueryHelpers.AddQueryString(clientPath.AbsoluteUri, new Dictionary <string, string> { [nameof(ResetPasswordView.UserId)] = user.Id, [nameof(ResetPasswordView.Token)] = token }); await _emailService.SendResetPasswordAsync(user.Email, resetUrl); }
public static int ForgotPasswordApply(ForgotPasswordView model) { var result = 0; using (var conn = new SqlConnection(connectionString)) { conn.Open(); var cmdText = string.Format("insert into ForgotPassword values(N'{0}', N'{1}', N'{2}', N'{3}', N'{4}', {5}, '{6}')", model.Email, model.UserName, model.Sex, model.Nick, model.Tel, 0, DateTime.Now); using (var cmd = new SqlCommand(cmdText, conn)) { result = cmd.ExecuteNonQuery(); conn.Close(); } } return(result); }
public async Task ForgotPassword(ForgotPasswordView model) { var user = await _userManager.FindByEmailAsync(model.Email); bool isConfirmEmail = await _userManager.IsEmailConfirmedAsync(user); if (user != null || isConfirmEmail) { string themOfMessage = "Reset your password"; string nameActionOnController = "reset"; var code = await _userManager.GeneratePasswordResetTokenAsync(user); string encodedCode = HttpUtility.UrlEncode(code); var userId = user.Id; await SendEmailAsync(user.Email, encodedCode, userId, themOfMessage, nameActionOnController); } }
public ActionResult ForgotPassword(ForgotPasswordView forgotPasswordView) { if (ModelState.IsValid) { var user = Repository.Users.FirstOrDefault(p => string.Compare(p.Email, forgotPasswordView.Email, true) == 0); if (user != null) { NotifyMail.SendNotify("ForgotPassword", user.Email, format => string.Format(format, HostName), format => string.Format(format, user.Email, user.Password, HostName)); return(View("ForgotPasswordSuccess")); } ModelState.AddModelError("Email", "Email user not found"); } return(View(forgotPasswordView)); }
public async Task <IActionResult> ForgotPassword(ForgotPasswordView model) { if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(model.Email); if (user != null && await _userManager.IsEmailConfirmedAsync(user)) { var token = await _userManager.GeneratePasswordResetTokenAsync(user); var passwordResetLink = Url.Action("ResetPassword", "Account", new { email = model.Email, token = token }, Request.Scheme); return(View(model)); } return(View(model)); } return(View(model)); }
public static ForgotPasswordView GetForgotPasswordById(int id) { var result = new ForgotPasswordView(); using (var conn = new SqlConnection(connectionString)) { conn.Open(); var cmdText = string.Format("select * from ForgotPassword"); using (var cmd = new SqlCommand(cmdText, conn)) { var reader = cmd.ExecuteReader(); while (reader.Read()) { result = SqlReaderForgotPassword(reader); } } } return(result); }
public async Task <ActionResult> ForgotPassword(ForgotPasswordView 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 code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); // var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>"); // return RedirectToAction("ForgotPasswordConfirmation", "Account"); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task ForgotPassword(ForgotPasswordView model) { await _httpClientService.PostJsonAsync(_apiOptions.ForgotPassword, model); }
void OnClickButtonForgot(GameObject go) { ForgotPasswordView.Create(); }
public async Task <IActionResult> ForgotPassword([FromBody] ForgotPasswordView model) { await _accountService.ForgotPassword(model); return(Ok()); }
public void AddForgotPasswordApply(ForgotPasswordView model) { accountClient.AddForgotPassword(model); }