public ActionResult ChangeForgotten(string code, ForgotPasswordModel model) { try { if (ModelState.IsValid) { var dal = GetDAL <UsersLayer>(); var crypto = new AESCypto(); var codes = crypto.DecryptText(code).Split(','); if (codes[0] == "aes") { int userId = int.Parse(codes[1]); var email = dal.GetEmail(userId); var oldPassword = dal.GetOldPassword(userId); var newPassword = GetMD5(model.NewPassword); dal.ChangeMyPassword(email, oldPassword, newPassword); TempData["message"] = "Password change successful"; return(RedirectToAction("Index")); } } else { ViewBag.IsReady = "1"; } } catch (Exception) { } return(View(model)); }
public ActionResult ChangeForgotten(string code) { try { var crypto = new AESCypto(); var codes = crypto.DecryptText(code).Split(','); if (codes[0] == "aes" && DateTime.Parse(codes[2]) > DateTime.Now.AddDays(-1)) { ViewBag.IsReady = "1"; } } catch (Exception) { } return(View(new ForgotPasswordModel())); }