public ActionResult ChangePassword(FormCollection collection) { if (Session["USER"] != null) { UserBUS bus = new UserBUS(); UserDTO user = (UserDTO)Session["USER"]; string oldPass = collection["txtOldPassword"]; string newPass = collection["txtNewPassword"]; if (!user.Password.Equals(oldPass)) { ViewData["RESULT"] = "0"; return View(); } else { Feature f = new Feature(); ViewData["RESULT"] = f.ChangePassword(user, newPass) ? "1" : "0"; return View(); } } return RedirectToAction("Index", "Home"); }
public ActionResult ResetPassword(FormCollection collection) { UserBUS bus = new UserBUS(); UserDTO user = bus.GetUserById(collection["txtUserId"]); if (user == null) { ViewData["RESULT"] = "0"; } else { ViewData["RESULT"] = "1"; Feature f = new Feature(); f.ResetPassword(user); } return View(); }
public ActionResult LogOn(LogOnModel model, string returnUrl) { UserBUS bus = new UserBUS(); var user = bus.GetUserById(model.UserName.ToLower()); if (user != null && user.Password.Equals(model.Password)) { Session.Add("USER", user); Log.Info("User Logged In"); if (!String.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ViewData.Add("LogOnError", "Tên đăng nhập không tồn tại hoặc mật khẩu bị sai. Xin vui lòng kiểm tra lại!"); } // If we got this far, something failed, redisplay form return View(model); }