case 4720 - restricted roles get filtered work order items in report data, rendering and export
Opening a work order filters it for restricted users (TechRestricted, SubContractor, SubContractorRestricted): only items they are scheduled on, and on those only their own labour, travel and scheduling, and for some roles no parts, units, expenses etc. Report data, rendering and export went through WorkOrderGetPartialAsync, which filtered nothing for child types (security review F27). Two causes: - the partial fetch now applies the same filtering: the item only if the user is scheduled on it (checked in the database), then its details filtered; the existing per-item filtering moved unchanged into RemoveRestrictedUserItemDetails so both fetches share it; - BizObjectFactory created WorkOrderBiz with UserType.Service for everyone, so in these paths a subcontractor was never treated as one; it now passes the user's real type (only the subcontractor flags depend on it). Checked: report data for a restricted subcontractor on work order 1 went from the whole item with parts to none; scheduled on an item, it gets the item without parts or other users' labour. Full suite: 111 passed, 5 skipped, the same 2 known failures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using AyaNova.Util;
|
||||
using AyaNova.Models;
|
||||
|
||||
@@ -91,7 +93,9 @@ namespace AyaNova.Biz
|
||||
case AyaType.WorkOrderItemTravel:
|
||||
case AyaType.WorkOrderItemUnit:
|
||||
case AyaType.WorkOrderItemOutsideService:
|
||||
return new WorkOrderBiz(ct, userId, translationId, roles, UserType.Service);
|
||||
//case 4720: the real user type, the subcontractor restrictions depend on it (report data and export come through here)
|
||||
var workOrderUserType = ct.User.AsNoTracking().Where(z => z.Id == userId).Select(z => z.UserType).FirstOrDefault();
|
||||
return new WorkOrderBiz(ct, userId, translationId, roles, workOrderUserType);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user