public ActionResult Login(string userName = "", string password = "") { if (string.IsNullOrWhiteSpace(userName)) { userName = Convert.ToString(Session["Supplier_SearchValue"]); } Session["userName"] = userName; if (Request.HttpMethod == "POST") { var account = AccountService.Authorize(userName, CryptHelper.Md5(password)); if (account == null) { ModelState.AddModelError("", "Thông tin đăng nhập bị sai"); return(View()); } // Ghi nhận Cookie cho phiên đăng nhập FormsAuthentication.SetAuthCookie(CookieHelper.AccountToCookieString(account), false); // Quay về trang chủ return(RedirectToAction("Index", "Home")); } else { return(View()); } }
/// <summary> /// /// </summary> /// <returns></returns> // GET: Account public ActionResult Login(string loginName = "", string password = "") { ViewBag.LoginName = loginName; if (Request.HttpMethod == "POST") { var account = AccountService.Authorize(loginName, CryptHelper.Md5(password)); if (account == null) { ModelState.AddModelError("", "thông tin đăng nhập bị sai"); return(View()); } var photoLink = PhotoLinkHelper.photoLink(AccountService.getEmployeePhotoByEmail(loginName)); if (string.IsNullOrEmpty(photoLink)) { photoLink = ""; } FormsAuthentication.SetAuthCookie(CookieHelper.AccountToCookieString(account), false); Session.Add("photoLink", photoLink); Session.Add("fullName", account.FullName); Session.Add("loginName", loginName); return(RedirectToAction("Index", "Home")); } else { return(View()); } }
// GET: Account public ActionResult Login(string loginName = "", string password = "") { ViewBag.LoginName = loginName; if (Request.HttpMethod == "POST") { var account = AccountService.Authorize(loginName, CryptHelper.Md5(password)); if (account == null) { ModelState.AddModelError("", "Thông tin đăng nhập bị sai"); return(View()); } System.Web.Security.FormsAuthentication.SetAuthCookie(CookieHelper.AccountToCookieString(account), false); return(RedirectToAction("Index", "Home")); } else { return(View()); } }