public async Task <ActionResult> ResetPassword(Models.NewPassword model) { if (ModelState.IsValid) { using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { using (var conn = new EntityConnection(ConfigurationManager.ConnectionStrings["TCFPEntities"].ConnectionString)) { await conn.OpenAsync(); using (var context = new TCFPEntities(conn, false)) { int affectedRecord = context.sp_ResetPassword(TempData[TokenIDKey].ToString(), model.Password); if (affectedRecord == 0) { ModelState.AddModelError("E0009", Resources.Message.E0009); } else { ViewBag.Message = Resources.Message.I0002; } } } scope.Complete(); } return(View()); } else { return(View()); } }
public async Task <IActionResult> NewPassword(Models.NewPassword args) { ViewData["Title"] = "New Password"; if (!ModelState.IsValid) { return(View()); } var bll_user = endUserBusiness; var user = await bll_user.GetById(args.EndUser.UserId); var salt = Core.Crypto.GenerateSalt(); var enc = Core.Crypto.Hash(args.Password, salt); user.PasswordHash = enc; user.PasswordSalt = Convert.ToBase64String(salt); user.LastPasswordChanged = DateTime.Now; user.DateConfirmed = user.LastPasswordChanged; user.DateConfirmed = DateTime.Now; user.ConfirmationCode = null; user.ConfirmationExpiry = null; user.DateInactive = null; await bll_user.Edit(user); return(await Index(new Models.Login { Email = user.Member.Email, Password = args.Password })); }