# Phase 8 — Access-control and facility-isolation hardening

## Source changes
- Active-account middleware now runs on authenticated web and API routes. Accounts disabled after login are denied on subsequent requests.
- Forced password change now returns a JSON 403 response for API clients and redirects browser sessions to the password-change screen.
- Patient create/edit operations require designated registration roles and an assigned facility.
- Patient encounter history is scoped to the signed-in user's facility unless the user holds an explicitly LCDA-wide role.
- Encounter creation checks approved-transfer patient access, requires a clinical role and records the encounter at the user's current facility.
- Appointment creation and status changes require authorised roles and a facility assignment.
- Clinical observations require an appropriate clinical role.
- Patient transfers can be initiated by authorised staff from their current facility, including onward transfers for patients already transferred in.
- Pharmacy, laboratory, maternal, child-health, emergency and referral screens/actions have additional role checks.
- HR, inventory, finance, surveillance, performance and document screens/actions have role gates.
- Audit events use the affected record's facility ID where the record exposes one.

## Verification evidence
- PHP source syntax checks are run using `php -l`.
- JavaScript source syntax checks are run using `node --check`.
- Static route-name and controller-method reference checks are run.
- Feature-test source covers forced password change, disabled-account denial, role-escalation denial and approved-transfer visibility.

## Still outstanding
- Composer dependency resolution and Laravel boot.
- Database migrations and all feature tests against a real test database.
- Independent role/action matrix review and cross-facility penetration tests.
- MFA, password reset/recovery, email verification and session/device management.
- Audit log tamper resistance and external SIEM/retention integration.
- Formal clinical/privacy/security acceptance before real patient data.
