public ActionResult Index(string urlPrefix, string Username, string Password, bool?Remember) { qtUserService _user = new qtUserService(); if (_user.CheckUserLogin(Username, EncryptUtil.EncryptMD5(Password))) { qtUser user = _user.GetUserLogin(Username, EncryptUtil.EncryptMD5(Password)); if (user != null) { if (Remember != null && Remember == true) { HttpCookie ckUsername = new HttpCookie("username"); ckUsername.Expires = DateTime.Now.AddSeconds(3600); ckUsername.Value = Username; Response.Cookies.Add(ckUsername); HttpCookie ckPassword = new HttpCookie("password"); ckPassword.Expires = DateTime.Now.AddSeconds(3600); ckPassword.Value = EncryptUtil.EncryptMD5(Password); Response.Cookies.Add(ckPassword); } HttpContext.User.Identity.SetUserLogin( new Account(user.UserId, user.UserName, user.UserLogin, user.Password, user.Address, user.Sex.ToString(), user.Email, user.Tel, user.Phone, user.Notes, user.UnitId.ToString(), string.Empty, user.DepartmentId.ToString(), string.Empty, user.PositionId.ToString(), string.Empty) ); string url = String.Empty; if (String.IsNullOrEmpty(urlPrefix)) { url = QuanTriHelper.GetFirstPermissionUrlByUser(user, Config.Application); } else { url = urlPrefix; } // fix url = "/DanhMuc/BaoCao/Index"; if (!string.IsNullOrEmpty(url)) { return(Redirect(url)); } else { ModelState.AddModelError("", "Tài khoản chưa được phân quyền"); } return(View()); } else { ModelState.AddModelError("", "Tài khoản không tồn tại trong hệ thống"); } } else { ModelState.AddModelError("", "Tên đăng nhập hoặc mật khẩu không đúng"); } return(View()); }
public ActionResult Index(string urlPrefix) { ViewBag.urlPrefix = urlPrefix; qtUser userCookie = CheckCookie(); if (userCookie != null) { qtUserService _user = new qtUserService(); if (_user.CheckUserLogin(userCookie.UserLogin, userCookie.Password)) { qtUser user = _user.GetUserLogin(userCookie.UserLogin, userCookie.Password); if (user != null) { HttpContext.User.Identity.SetUserLogin( new Account(user.UserId, user.UserName, user.UserLogin, user.Password, user.Address, user.Sex.ToString(), user.Email, user.Tel, user.Phone, user.Notes, user.UnitId.ToString(), string.Empty, user.DepartmentId.ToString(), string.Empty, user.PositionId.ToString(), string.Empty) ); string url = String.Empty; if (String.IsNullOrEmpty(urlPrefix)) { url = QuanTriHelper.GetFirstPermissionUrlByUser(user, Config.Application); } else { url = urlPrefix; } // fix url = "/DanhMuc/BaoCao/Index"; if (!string.IsNullOrEmpty(url)) { return(Redirect(url)); } else { ModelState.AddModelError("", "Tài khoản chưa được phân quyền"); } return(View()); } else { ModelState.AddModelError("", "Tài khoản không tồn tại trong hệ thống"); } } else { ModelState.AddModelError("", "Tên đăng nhập hoặc mật khẩu không đúng"); } } return(View()); }