mirror of
https://github.com/hargata/lubelog.git
synced 2025-12-10 17:20:15 -06:00
only init endpoint list if vehicleId is 0.
This commit is contained in:
parent
baf9e8e833
commit
78408427b8
@ -17,7 +17,6 @@ namespace CarCareTracker.Filter
|
|||||||
}
|
}
|
||||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||||
{
|
{
|
||||||
var shopSupplyEndpoints = new List<string> { "ImportToVehicleIdFromCsv", "GetSupplyRecordsByVehicleId", "ExportFromVehicleToCsv" };
|
|
||||||
if (!filterContext.HttpContext.User.IsInRole(nameof(UserData.IsRootUser)))
|
if (!filterContext.HttpContext.User.IsInRole(nameof(UserData.IsRootUser)))
|
||||||
{
|
{
|
||||||
var vehicleId = int.Parse(filterContext.ActionArguments["vehicleId"].ToString());
|
var vehicleId = int.Parse(filterContext.ActionArguments["vehicleId"].ToString());
|
||||||
@ -28,11 +27,15 @@ namespace CarCareTracker.Filter
|
|||||||
{
|
{
|
||||||
filterContext.Result = new RedirectResult("/Error/Unauthorized");
|
filterContext.Result = new RedirectResult("/Error/Unauthorized");
|
||||||
}
|
}
|
||||||
} else if (shopSupplyEndpoints.Contains(filterContext.RouteData.Values["action"].ToString()) && !_config.GetServerEnableShopSupplies())
|
} else
|
||||||
|
{
|
||||||
|
var shopSupplyEndpoints = new List<string> { "ImportToVehicleIdFromCsv", "GetSupplyRecordsByVehicleId", "ExportFromVehicleToCsv" };
|
||||||
|
if (shopSupplyEndpoints.Contains(filterContext.RouteData.Values["action"].ToString()) && !_config.GetServerEnableShopSupplies())
|
||||||
{
|
{
|
||||||
//user trying to access shop supplies but shop supplies is not enabled by root user.
|
//user trying to access shop supplies but shop supplies is not enabled by root user.
|
||||||
filterContext.Result = new RedirectResult("/Error/Unauthorized");
|
filterContext.Result = new RedirectResult("/Error/Unauthorized");
|
||||||
} else if (!shopSupplyEndpoints.Contains(filterContext.RouteData.Values["action"].ToString()))
|
}
|
||||||
|
else if (!shopSupplyEndpoints.Contains(filterContext.RouteData.Values["action"].ToString()))
|
||||||
{
|
{
|
||||||
//user trying to access any other endpoints using 0 as vehicle id.
|
//user trying to access any other endpoints using 0 as vehicle id.
|
||||||
filterContext.Result = new RedirectResult("/Error/Unauthorized");
|
filterContext.Result = new RedirectResult("/Error/Unauthorized");
|
||||||
@ -41,3 +44,4 @@ namespace CarCareTracker.Filter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user