public bool ResetPassword(ResetPasswordViewModel ressetPassVM) { User user = db.Users.FirstOrDefault(x => x.Email == ressetPassVM.Email && x.ResetPassword == ressetPassVM.ResetCode); if (user != null) { try { var hash = Encoding.ASCII.GetBytes("san" + ressetPassVM.Password); var sha1 = new SHA1CryptoServiceProvider(); byte[] sha1hash = sha1.ComputeHash(hash); var hashedPassword = System.Text.Encoding.ASCII.GetString(sha1hash); user.PassWord = hashedPassword; db.SaveChanges(); return true; } catch (Exception e) { return false; } } return false; }
public ActionResult ResetPassword(ResetPasswordViewModel resetPassVM) { if (ModelState.IsValid) { ViewBag.Title = "Kết reset mật khẩu"; if (bus.ChangePassword(resetPassVM)) { ViewBag.Message = "Đổi khẩu thành công."; return View("Result"); } else { ViewBag.Message = "Đổi mật khẩu thất bại."; return View("Result"); } } return View(resetPassVM); }
public bool ChangePassword(ResetPasswordViewModel ressetPassVM) { return dal.ResetPassword(ressetPassVM); }