public static bool IsOwner(Controller controller) { using (AircraftContext db = new AircraftContext()) { return(db.Administrators.Where(m => m.Login == controller.User.Identity.Name).Single().AccessLevel == "Власник"); } }
//[ValidateAntiForgeryToken] public ActionResult Login(LoginModel model) { if (ModelState.IsValid) { // поиск пользователя в бд Administrator user = null; using (AircraftContext db = new AircraftContext()) { user = db.Administrators.FirstOrDefault(u => u.Login == model.Login && u.Password == model.Password); } if (user != null) { FormsAuthentication.SetAuthCookie(model.Login, true); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Користувача з таким логіном і паролем немає"); } } return(View(model)); }
public AircraftController(AircraftContext context) { _context = context; }