public ActionResult RecoveryPasswordPartial(RecoveryPasswordModel m) { if (m.Password == m.ConfirmPassword) { var pass = HashHelper.GetMd5Hash(m.Password); var operation = new SetPasswordOperation(pass, m.TokenHash); operation.ExcecuteTransaction(); if (operation.Success) { var user = operation._user; ViewBag.Success = true; return(SetSessionData(user)); } else { ErrorHelpers.AddModelErrors(ModelState, operation.Errors); } } else { ModelState.AddModelError("Password", "Пароли не совпадают!"); ViewBag.Success = false; } return(PartialView(m)); }
public async Task <IActionResult> RecoveryPassword([FromBody] RecoveryPasswordModel model) { if (!ModelState.IsValid) { return(BadRequest()); } await _identityServiceProvider.RecoveryPasswordAsync(model); return(NoContent()); }
public ActionResult RecoveryPassword(RecoveryPasswordModel model) { if (!ModelState.IsValid) { return(View(model)); } //if if (RemontinkaServer.Instance.SecurityService.RecoveryPassword(model.NewPassword, model.RecoveryNumber, Request.UserHostAddress)) { return(View("ChangePasswordSuccess")); } //if return(View("RecoveryFail")); }
public async Task <HttpResponseMessage> PasswordRecovery([FromBody] RecoveryPasswordModel user) { var status = default(Code); var dbuser = store.Users.FirstOrDefault(u => u.Email.ToLower().CompareTo(user.email.ToLower()) == 0); dynamic response = null; if (dbuser != null) { if (dbuser.IsDeleted == null || (dbuser.IsDeleted != null && !dbuser.IsDeleted.Value)) { int passLength = 6; if (!int.TryParse(ConfigurationManager.AppSettings["newPassLength"], out passLength)) { passLength = 6; } string password = PasswordGenerator.GetPassword(passLength); dbuser.Password = PasswordGenerator.GetPasswordSHA1(password, dbuser.Salt); store.SaveChanges(); /*MailAddress to = new MailAddress(dbuser.Email); * MailMessage message = new MailMessage(); * message.To.Add(to); * message.Subject = message.Subject = System.Configuration.ConfigurationManager.AppSettings["resetPass_EmailSubject"]; * string str = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("~/Email/PasswordRecovery.html")); * message.Body = String.Format(str, dbuser.FirstName, dbuser.LastName, "http://" + user.host, dbuser.UserName, password); * message.IsBodyHtml = true; * SmtpClient client = new SmtpClient(); * try * { * client.Send(message); * } * catch (Exception exc) * { * status = Code.EmailSendFailed; * }*/ } else { status = Code.UserHasDeleted; } } else { status = Code.UserWithEmailNotFound; } return(Request.CreateResponse(HttpStatusCode.OK, ApiResponseManager.CreateResponse(new Status(status), (object)response))); }
public async Task RecoveryPasswordAsync(RecoveryPasswordModel recoveryPasswordModel) { var verifyingUser = await _userManager.FindByIdAsync(recoveryPasswordModel.UserId); if (verifyingUser != null) { var result = await _userManager.ResetPasswordAsync(verifyingUser, recoveryPasswordModel.ValidateCode, recoveryPasswordModel.NewPassword); if (!result.Succeeded) { throw new IdentityException(new Core.Exceptions.ErrorCode { MessageCode = result.Errors.First().Code, MessageContent = result.Errors.First().Description }); } } }
/// <summary> /// Recuperacion de Password /// </summary> /// <param name="recoveryPasswordModel"></param> /// <returns></returns> private string recoveryPassword(RecoveryPasswordModel recoveryPasswordModel) { var model = recoveryPasswordModel; var emailTemplatePath = ""; if (recoveryPasswordModel.Idioma == IdiomaConstants.ESPANIOL) { emailTemplatePath = Path.Combine(TemplateFolderPath, ModelTemplates.CatalogTemplatesMail.RECOVERY_PASWWORD_TEMPLATE_ES_MX); } else { emailTemplatePath = Path.Combine(TemplateFolderPath, ModelTemplates.CatalogTemplatesMail.RECOVERY_PASWWORD_TEMPLATE_EN_US); } var templateService = new TemplateService(); var emailHtmlBody = templateService.Parse(File.ReadAllText(emailTemplatePath), model, null, null); return((String)emailHtmlBody); }
public async Task <IActionResult> RecoveryPassword([FromForm] RecoveryPasswordModel request) { if (User.Identity.IsAuthenticated) { return(RedirectToAction(nameof(AccountController.Login), "Account")); } if (!ModelState.IsValid) { return(View(nameof(RecoveryPassword), request)); } var result = await _mediator.Send(Application.PasswordManagement.RecoveryPassword.Command.New(request.Username)); if (!result.Succeeded) { AddErrors(result); return(View(nameof(RecoveryPassword), request)); } return(View("RecoveryPasswordEmailSent")); }