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