fix(permissions): apply the patient and tag read gates to invited clinic doctors
PatientController::resolveScope and TenantTagController::guardTagView only ever checked the secretary, while every write in both controllers already ran through both checkers. So an invited clinic doctor with patients.view off got 200 with an empty list where a secretary got 403 — one permission, two behaviours. No data was exposed either way; tenant scoping emptied the result. The fix is not canOrNonMember. That collapses two different situations: a membership row switched to active=false means the collaboration ended, and ClinicDoctorPermission::can() returns false for everything in that case too. Routing it through the permission gate turned the existing 404 on a single record into a 403, which confirms the record exists to someone who just lost access. ClinicRecordAccessTest caught it. isActiveMemberDenied() answers the narrower question — active member, permission off — and leaves a deactivated row to the data scope, which closes it with a 404 and discloses nothing. A test now pins that distinction so it cannot be collapsed again. Tags keep the tags.view OR patients.view rule, now for both roles. Verified live in three states: active with both off 403/403, deactivated not 403, active with patients.view on 200/200. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -145,7 +145,7 @@ Create a secretary for a doctor.
|
||||
| Resource | Enforced in | Action → endpoint |
|
||||
| --- | --- | --- |
|
||||
| `appointments` | `AppointmentAccessChecker`, `MyAppointmentsController`, `DashboardController` | view/create/cancel/update_status |
|
||||
| `patients` | `PatientController` (خواندنها via `scope()` → بدون `view` هیچ پروندهای؛ افزودن/ویرایشِ زیرآیتمها = `update`؛ **حذفِ** یادداشت/سند/رکورد/تماس/پیام = `delete` — جدا از `update`) | view/create/update/delete |
|
||||
| `patients` | `PatientController` (خواندنها via `scope()` → بدون `view` هیچ پروندهای — همین قاعده برای پزشکِ عضوِ **فعالِ** کلینیک هم اعمال میشود؛ افزودن/ویرایشِ زیرآیتمها = `update`؛ **حذفِ** یادداشت/سند/رکورد/تماس/پیام = `delete` — جدا از `update`) | view/create/update/delete |
|
||||
| `payments` | `PaymentController::myPayments`, `PaymentMethodController` (bank/pos), `PatientController` (کیفپول + پرداختِ جلسه) | view/create/update/delete |
|
||||
| `addresses` | `AddressController::list` (`GET /api/v1/addresses`). فقط `view`؛ نوشتنها owner-onlyاند. تا پیش از این این فهرست روی `appointment_settings.view` سوار بود و توگلِ آدرسها بیاثر بود | view |
|
||||
| `insurances` | `InsuranceController` (insurance-pricing, tenant-insurances, service-coverage, doctor-insurance) | view/create/update/delete |
|
||||
|
||||
Reference in New Issue
Block a user