public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", OptimaJet.Localization.LocalizationProvider.Provider.Get("Authentication failed. Try again.")); } } return View(model); }
public JsonResult JsonLogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); return Json(new {success = true, redirect = returnUrl}); } ModelState.AddModelError("", "The user name or password provided is incorrect."); } return Json(new {errors = GetErrorsFromModelState()}); }