Files
yara724api/docs/expert-access-and-optional-voice.md
SepehrYahyaee 83376df4ad feat: manage expert access and merge Parsian expert seeds
Allow role-specific identities and admin account activation, support national-code-only claim experts, and remove required voice from v4/v5. Add a combined, resumable Parsian seed that preserves existing accounts and merges locations and product codes.
2026-11-18 17:16:26 +03:30

46 lines
4.1 KiB
Markdown

# Expert access, multiple roles and optional voice
## Account activation
In the expert panel, a super-admin selects an insurer, opens **اعضا و کارشناسان → مدیریت**, and uses **غیرفعال کردن / فعال کردن** beside the relevant role account. Insurers can see the status but cannot change it.
The endpoint is:
```http
PATCH /super-admin/management/staff/:role/:id/status?clientId=<insurer-id>
Authorization: Bearer <super-admin-token>
Content-Type: application/json
{"isActive": false}
```
Only a boolean is accepted. The selected account must belong to the supplied insurer. The response excludes passwords and OTPs. The general staff-edit endpoints, including insurer endpoints, do not accept `isActive`.
Supported roles: `expert`, `damage_expert`, `field_expert`, `file_maker`, `file_reviewer`, `call_center`. Disabling one role account does not disable another role account belonging to the same person. Login and protected expert requests check the saved flag; previously issued tokens cannot be used while that account is disabled. Existing documents without `isActive` are treated as active.
No existing account, password, case owner or assignment is migrated. Deploy the API before the updated expert UI. No database backfill or index deletion is needed.
## Same person in several flows
Create an account for each required role using the same national code, email and password. Continue using the existing login URLs and role selectors. For example, one person can log into `/v4/expert-login` as either a file maker or a file reviewer with the same credentials, provided both assignments have been created. The expert panel likewise uses its existing role selector.
The creation and edit checks now reject duplicate identifiers **within the selected role**, rather than across all roles. Role collections already have separate indexes, so cross-role reuse requires no production index changes. Within-role uniqueness remains important because login has no insurer selector. This change does not grant another role automatically or merge existing records.
Credentials remain attached to their existing role records. Administrators should enter the same password when adding another role; changing one role's password does not silently overwrite credentials on another production account. National codes on existing accounts should only be corrected after verifying the person's identity.
## Voice in v4/v5
FileMaker flows v4 and v5 no longer display or require the blame voice recorder. Following each party's inquiry, the workflow goes to written details, then signature. Written accident information, car-body description validation, signatures, required documents and reviewer handoff remain in place.
Older v4/v5 files waiting at `FIRST_VOICE` or `SECOND_VOICE` resume at the corresponding description step. The details page fetches the FileMaker's case through its own `my-files/:requestId` endpoint, with loading/retry states, so reopening does not depend on a previously cached party or case type. The voice-permission notice is also hidden in these flows. Existing recordings, completed-step history and events are retained. The optional upload endpoints are retained for older clients. Other flows keep their voice requirements. The separate claim walk-around video requirement is unchanged.
## Verification
- Management tests exercise real Mongoose schemas, cross-role creation/editing, same-role duplicate rejection, activation/reactivation, legacy defaults and tenant boundaries.
- HTTP tests use the real management/auth controllers and JWT guards with isolated repositories to verify login, status permissions, rejection of an old token, and the other role remaining usable.
- Auth tests cover all staff roles and JWT guard entry points.
- Workflow tests cover v4/v5, car-body/third-party, both parties, signatures without voice and older resume states.
- Frontend regression scripts cover the status proxy allowlist and v4/v5 submission without voice while retaining the other flows' requirements.
Run the API suite with `npm test -- --runInBand`, and each frontend suite with `npm run test:ui`. These checks do not use production data or send SMS messages.