Allow sharing Reports Hub saved reports with inspectors (Access Permissions)
Objective
- Users with Reports Hub (
data-exports) permission should be able to receive restricted saved reports (non-publicallowedUserIds) the same way office staff can—including inspectors. - Today inspectors can see public reports when they have the permission, but the share UI does not let creators add them to the allowed list.
Background
- Public saved reports (
allowedUserIdsempty) are visible to everyone in the company who can callGET /data-exports; list filtering treats empty lists as company-wide (attik-backend/src/routes/dataExport.ts). - Restricted reports require the viewer’s id in
allowedUserIds(or they are the creator). Access checks useres.locals.membership?.employeeId || res.locals.membership?._officeStaffIdin several places—not_inspectorId(dataExport.ts). - The Access Permissions control in the report builder uses
UserSelector, which only loads active office staff fromoffice-staffand never lists inspectors (attik-frontend/src/components/data-exports/UserSelector.tsx). - The Reports Hub list page also only fetches office staff for related UI (
attik-frontend/src/app/tools/data-exports/page.tsx). - Membership
employeeIdmay point to either office staff or inspector per schema (attik-backend/src/models/membershipSchema.ts); align UI and API so inspector recipients work end-to-end.
Scope (for implementer)
- Frontend: Extend user picking for
allowedUserIdsto include inspectors (e.g. merge office staff + inspectors, clear labeling, same active/relevant filters as elsewhere). Any list/detail UI that assumes “office staff only” for share display may need updates. - Backend: Ensure
userCanAccessReportand alldata-exportsroutes that gate oncurrentUserEmployeeIdresolve the current user consistently for inspector memberships (employeeIdand/or_inspectorIdas needed) so shared reports are visible, editable, and exportable per existing rules. - Tests: Add or extend integration coverage analogous to
tests/integration/dataExport.sharedAccess.test.tsfor an inspector recipient.
References
attik-frontend/src/components/data-exports/UserSelector.tsxattik-frontend/src/app/tools/data-exports/CreateReportForm.tsx(Access Permissions)attik-backend/src/routes/dataExport.ts(userCanAccessReport,GET /,GET /:id, export routes)attik-backend/src/models/membershipSchema.ts
Status: Completed
Log in to comment and vote
No comments yet
Be the first to share your thoughts.