public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid && Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); return RedirectToLocal(returnUrl); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "Authentication failed. Please try again."); return View(model); }
public ActionResult Login(LoginModel model, string returnUrl) { try { if (ModelState.IsValid && ValidateUser(model.UserName, model.Password)) { if (model.Password.Equals("Password1")) { return RedirectToAction("ChangePassword"); } else return RedirectToLocal(); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return View(model); } ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }