Fix CollaboratorFilter bug.

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD 2024-11-30 12:23:48 -07:00
parent 244272621c
commit 5f357c9f84

View File

@ -18,6 +18,8 @@ namespace CarCareTracker.Filter
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (!filterContext.HttpContext.User.IsInRole(nameof(UserData.IsRootUser)))
{
if (filterContext.ActionArguments.ContainsKey("vehicleId"))
{
var vehicleId = int.Parse(filterContext.ActionArguments["vehicleId"].ToString());
if (vehicleId != default)
@ -27,7 +29,8 @@ namespace CarCareTracker.Filter
{
filterContext.Result = new RedirectResult("/Error/Unauthorized");
}
} else
}
else
{
var shopSupplyEndpoints = new List<string> { "ImportToVehicleIdFromCsv", "GetSupplyRecordsByVehicleId", "ExportFromVehicleToCsv" };
if (shopSupplyEndpoints.Contains(filterContext.RouteData.Values["action"].ToString()) && !_config.GetServerEnableShopSupplies())
@ -41,6 +44,10 @@ namespace CarCareTracker.Filter
filterContext.Result = new RedirectResult("/Error/Unauthorized");
}
}
} else
{
filterContext.Result = new RedirectResult("/Error/Unauthorized");
}
}
}
}