public JsonResult JsonLogin(LoginModel model, string returnUrl) { if (ModelState.IsValid) { var user = RavenSession.Query<User>().FirstOrDefault(u => u.Name == model.UserName); if (user != null && user.ValidatePassword(model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); return Json(new { success = true, redirect = returnUrl }); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed return Json(new { errors = GetErrorsFromModelState() }); }
public ActionResult Login(LoginModel model) { if (ModelState.IsValid) { var user = GetUser(model.UserName, model.CommandCompanyId); if (user != null && user.ValidatePassword(model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(model.ReturnUrl)) { return Redirect(model.ReturnUrl); } else { return RedirectToAction("Index", "Competition"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult Login() { var model = new LoginModel(); model.ReturnUrl = Request.QueryString["returnUrl"]; return View(model); //return ContextDependentView(); }