public ActionResult Login(LoginModel model, string returnUrl) { Session["Permissions"] = new Ludus.Models.UserPermission(); if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, false)) { DataContext dc = new DataContext(); int userId = (from u in dc.UserProfiles where u.UserName == model.UserName select u.UserId).FirstOrDefault(); ((Ludus.Models.UserPermission)Session["Permissions"]).Fill (userId); 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 && 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); }