forked from Yara724/api
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.
This commit is contained in:
@@ -1143,7 +1143,7 @@
|
||||
<p class="section-intro">
|
||||
Two actors handle the same V3 work split across two controllers.
|
||||
<strong>FileMaker</strong> (<code>v4/file-maker/blame-request-management/</code>)
|
||||
handles the party narrative (OTPs, inquiries, details, signatures) and
|
||||
handles the party narrative (OTPs, inquiries, written details, signatures) and
|
||||
uploads the initial claim documents. <strong>FileReviewer</strong>
|
||||
(<code>v4/file-reviewer/blame-request-management/</code>) handles the
|
||||
damage assessment pass. The final blame video (upload-video) is a no-op
|
||||
@@ -1204,11 +1204,11 @@
|
||||
<div class="step-num purple">5</div>
|
||||
<div class="step-body">
|
||||
<div class="step-label">
|
||||
Location · description · voice (guilty)
|
||||
Written description (guilty; voice optional)
|
||||
</div>
|
||||
<div class="step-route">
|
||||
POST /add-detail-location, /add-detail-description,
|
||||
/upload-voice
|
||||
POST /add-detail-description
|
||||
(location skipped; voice not required)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# 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.
|
||||
@@ -24,6 +24,7 @@ All endpoints require bearer authentication and strictly validate their DTOs. Sw
|
||||
| Edit insurer login account | `PATCH /super-admin/management/clients/:clientId/accounts/:id` | Unavailable |
|
||||
| List/create staff | `GET/POST /super-admin/management/staff?clientId=...` | `GET/POST /expert-insurer/management/staff` |
|
||||
| Edit staff | `PATCH /super-admin/management/staff/:role/:id?clientId=...` | `PATCH /expert-insurer/management/staff/:role/:id` |
|
||||
| Activate/deactivate a staff role account | `PATCH /super-admin/management/staff/:role/:id/status?clientId=...` | Unavailable |
|
||||
| List/create branches | `GET/POST /super-admin/management/branches?clientId=...` | `GET/POST /expert-insurer/management/branches` |
|
||||
| Edit branch | `PATCH /super-admin/management/branches/:id?clientId=...` | `PATCH /expert-insurer/management/branches/:id` |
|
||||
|
||||
@@ -33,7 +34,9 @@ Staff list queries accept `search`, `role`, `page` and `limit` (default 20, capp
|
||||
|
||||
`role` is one of `expert`, `damage_expert`, `field_expert`, `file_maker`, `file_reviewer`, or `call_center`, and is selected only during creation. These use the existing collections and actor login mechanism.
|
||||
|
||||
Staff creation requires `firstName`, `lastName`, a ten-digit `nationalCode` and a password of at least six characters. Email and mobile are optional for field experts, file makers, file reviewers and call-center agents, matching the seed format. Blame and claim experts require email and mobile to match their existing account contracts. Seed-style accounts without email log in using their national code. National-code and email aliases cannot be duplicated across new managed accounts.
|
||||
Staff creation requires `firstName`, `lastName`, a ten-digit `nationalCode` and a password of at least six characters. Email and mobile are optional for claim experts, field experts, file makers, file reviewers and call-center agents, matching the seed format. Blame experts still require email and mobile. Seed-style accounts without email log in using their national code. National-code and email aliases can be reused across different roles; they remain unique within a role because login has no tenant selector. Create each required role with the same credentials to let one person use several flows. Existing records and passwords are preserved. The remaining-experts seed prepares sparse email indexes for older claim-expert databases before inserting email-less accounts.
|
||||
|
||||
Staff lists include `isActive`, treating older records with no flag as active. Only super-admins can change this flag using the status endpoint and a boolean body, e.g. `{"isActive": false}`. Disabled accounts cannot log in or reuse existing JWTs. Status belongs to the selected role account; the same person's other assignments are unaffected. See [expert access and optional voice](expert-access-and-optional-voice.md).
|
||||
|
||||
Common optional properties are `branchId`, `phone`, `mobile`, `email`, `city`, `state`, `address` and `expertCode`. A branch, when supplied, must belong to the account's insurer. `expertCode` and the role-specific Fanavaran IDs are positive integer strings, matching existing persistence and mapping contracts.
|
||||
|
||||
@@ -71,6 +74,6 @@ PATCH sends only changed fields. Omit `password` to preserve it; supply a replac
|
||||
|
||||
## Verification
|
||||
|
||||
`npm test -- --runInBand` includes schema-backed management tests for all six roles, optional seed fields, role-specific IDs, locations, tenant isolation, branch updates, account passwords, protected fields and strict DTO validation. The route contract keeps the 383 existing routes and adds 18 guarded management routes.
|
||||
`npm test -- --runInBand` includes schema-backed management tests for all six roles, optional seed fields, role-specific IDs, locations, tenant isolation, branch updates, account passwords, protected fields and strict DTO validation. The route contract retains the existing routes and records the additional super-admin status endpoint. HTTP tests cover cross-role login, activation, status permissions, and rejection of existing sessions after deactivation.
|
||||
|
||||
The expert UI's `npm run test:ui` includes management proxy and payload regression checks. Desktop/mobile browser checks use mocked local API responses, rather than modifying a real insurer. Live credential login, database indexes under concurrent writes and outbound Fanavaran submission remain integration QA responsibilities.
|
||||
|
||||
Reference in New Issue
Block a user