feat: add per-doctor permissions management in clinics
- Implement DoctorPermissionsModal for managing doctor permissions in clinics. - Create usePermissions hook to handle user permissions context. - Add migration for clinic_doctor_permissions table with default permissions. - Develop ClinicDoctorPermissionController for handling permissions API. - Create ClinicDoctorPermission entity to manage permissions data. - Implement ClinicDoctorPermissionRepository for database interactions. - Add ClinicDoctorPermissionChecker for permission validation logic. - Write tests for clinic doctor permissions functionality.
This commit is contained in:
+26
-2
@@ -287,8 +287,20 @@ Authorization: Bearer <token>
|
||||
"type": "clinic",
|
||||
"db_uuid": "clinic-uuid-...",
|
||||
"name": "کلینیک سلامت",
|
||||
"role": "clinic",
|
||||
"doctor_uuid": "a6ef5d29-38b8-4e69-b1ef-27a304696966"
|
||||
"role": "doctor",
|
||||
"scope": "clinic",
|
||||
"doctor_uuid": "a6ef5d29-38b8-4e69-b1ef-27a304696966",
|
||||
"permissions": {
|
||||
"version": 1,
|
||||
"resources": {
|
||||
"appointments": { "view": true, "create": true, "cancel": true, "update_status": true },
|
||||
"appointment_settings": { "view": true, "update": true },
|
||||
"patients": { "view": true, "create": true, "update": true, "delete": false },
|
||||
"payments": { "view": true, "create": false, "update": false, "delete": false },
|
||||
"services": { "view": true, "update": false },
|
||||
"clinic_info": { "view": true, "update": false }
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -304,6 +316,18 @@ Authorization: Bearer <token>
|
||||
| `context` | object\|null | context فعال انتخابشده |
|
||||
| `available_contexts` | array | همه محیطهای کاری قابل انتخاب |
|
||||
|
||||
**فیلد `permissions` در هر context:**
|
||||
|
||||
| حالت context | مقدار `permissions` |
|
||||
|---|---|
|
||||
| مطب شخصی پزشک (`type: doctor`، `role: doctor`) | `null` — محیط خودش، محدودیتی ندارد |
|
||||
| مالک کلینیک (`role: clinic`) | `null` — مالک هرگز محدود نمیشود |
|
||||
| پزشکِ عضو کلینیک (`role: doctor`، `scope: clinic`) | envelope کامل `{version, resources}` از `clinic_doctor_permissions` |
|
||||
| پزشکِ عضوی که دسترسیاش غیرفعال شده | `{version: 1, resources: {}}` — یعنی هیچ دسترسی |
|
||||
| منشی (`role: secretary`) | envelope کامل از `doctor_secretaries` |
|
||||
|
||||
نکتهٔ مهم برای کلاینت: **نبودِ `permissions` (یا `null`) یعنی «بدون محدودیت»، نه «بدون دسترسی».** ساختار و کلیدهای مجوز پزشکِ عضو کلینیک در `docs/api/clinic.md` → بخش *Clinic Doctor Permissions* آمده است.
|
||||
|
||||
**قانون `primary_role`** (اولویتبندی):
|
||||
- `ROLE_ADMIN` → `"admin"`
|
||||
- `ROLE_CLINIC` → `"clinic"`
|
||||
|
||||
Reference in New Issue
Block a user