public ActionResult Login(UserTable model, string returnUrl) { AirportDatabaseEntities db = new AirportDatabaseEntities(); model.Password = Encode(model.Password); var dataItem = db.UserTable.Where(x => x.Username == model.Username && x.Password == model.Password).FirstOrDefault(); if (dataItem != null) { FormsAuthentication.SetAuthCookie(dataItem.Username, false); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("", "Invalid user/pass"); return(View()); } }
public override string[] GetRolesForUser(string username) { AirportDatabaseEntities db = new AirportDatabaseEntities(); string data = db.UserTable.Where(x => x.Username == username).FirstOrDefault().Role; string[] result = { data }; return(result); }