public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { if (userRepository.ValidateLogin(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); return RedirectToLocal(returnUrl); } } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "Tên đăng nhập hoặc mật khẩu bị sai."); return View(model); }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { if (userRepository.ValidateLogin(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); bool isNotDefaul = returnUrl == "/" || returnUrl == "/Home"; return RedirectToLocal(isNotDefaul ? "/Home/Dashboard" : returnUrl); } } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { return RedirectToLocal(returnUrl); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { if (userRepository.ValidateLogin(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); bool isNotDefaul = returnUrl == "/" || returnUrl == "/Home"; var obj = userRepository.GetUserProfile(model.UserName); if (obj != null && obj.Company.CompanyType.TypeName == "Customer") return RedirectToLocal("/SDS/GetSDSAssignedCustomer"); return RedirectToLocal(isNotDefaul ? "/SDS/Index" : returnUrl); } } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }