From d3589e231cbc30b1f66f7a7442b7a41decb284f5 Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Tue, 27 May 2014 18:47:20 -0400 Subject: [PATCH] Correct authorization issue with city controller --- Web/Controllers/CityController.cs | 20 +++++++++++--------- Web/Controllers/CreateLogController.cs | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Web/Controllers/CityController.cs b/Web/Controllers/CityController.cs index 7e664f5..d6a1da1 100644 --- a/Web/Controllers/CityController.cs +++ b/Web/Controllers/CityController.cs @@ -7,16 +7,22 @@ using MileageTraker.Web.Utility; namespace MileageTraker.Web.Controllers { - [Authorize(Roles = "Administrator, Developer")] + [Authorize] public class CityController : ControllerBase { - [Authorize(Roles = "Administrator, Developer, Driver")] public JsonResult Autocomplete(string term) { var cities = DataService.GetCitiesAutocomplete(term); return Json(cities, JsonRequestBehavior.AllowGet); } + public JsonResult CityNameExists(string cityname) + { + var city = DataService.FindCityByName(cityname); + return Json(city != null, JsonRequestBehavior.AllowGet); + } + + [Authorize(Roles = "Administrator, Developer")] public ActionResult Index() { var cities = DataService.GetCities().ToList(); @@ -25,12 +31,14 @@ namespace MileageTraker.Web.Controllers return View(groupTuple); } + [Authorize(Roles = "Administrator, Developer")] public ActionResult Create(string county) { var city = new City {County = county}; return View(city); } + [Authorize(Roles = "Administrator, Developer")] [ActionLog] [HttpPost] public ActionResult Create([Bind(Exclude = "CityId")] City city) @@ -46,17 +54,11 @@ namespace MileageTraker.Web.Controllers return View(city); } + [Authorize(Roles = "Administrator, Developer")] public JsonResult CityNameAvailable(string name) { var city = DataService.FindCityByName(name); return Json(city == null, JsonRequestBehavior.AllowGet); } - - [Authorize(Roles = "Administrator, Developer, Driver")] - public JsonResult CityNameExists(string cityname) - { - var city = DataService.FindCityByName(cityname); - return Json(city != null, JsonRequestBehavior.AllowGet); - } } } diff --git a/Web/Controllers/CreateLogController.cs b/Web/Controllers/CreateLogController.cs index 035f20a..ddc5531 100644 --- a/Web/Controllers/CreateLogController.cs +++ b/Web/Controllers/CreateLogController.cs @@ -28,6 +28,7 @@ namespace MileageTraker.Web.Controllers } [HttpPost] + [ActionLog] public ActionResult Index(CreateLogViewModel model) { if (ModelState.IsValid)