Files
yara724-api/docs/claim-beneficiary-authorization.md
T
2026-10-05 16:40:54 +03:30

3.9 KiB

Claim beneficiary authorization

The shared user claim API supports the regular third-party and body-insurance flows. A third-party claim can be created only by the party opposite the recorded expert.decision.guiltyPartyId, after the blame case is COMPLETED and both parties have accepted and supplied signature files. Both identities must be present and distinct, and the guilty ID must match one of them. An unresolved decision does not grant either party claim creation. Body-insurance claims belong to the first party of the completed blame case.

helpers/blame-claim-eligibility.ts supplies the same eligibility rule to claim creation and the viewer's blame-list/detail guidance. An existing claim remains viewable by both parties, but only the beneficiary receives CONTINUE_CLAIM. Claim details include canAct; read-only viewers receive no owner action guidance. The user UI sends those viewers to the evaluation screen and hides signing, objections, and invoice-upload controls. An unrelated actor cannot create or mutate the claim.

New regular claims store the beneficiary in both owner.userId and damagedPartyUserId, as the in-person flows already do. owner.clientId and owner.userClientKey still identify the paying insurer (the guilty party's insurer for third-party claims). No existing database rows are rewritten.

For historical regular claims whose owner is the guilty party, mutation authorization resolves the beneficiary from the linked blame decision rather than granting owner access. Phone-linked user identities remain supported. When the source is unavailable, an explicit damagedPartyUserId is authoritative. Snapshot membership alone cannot establish liability because historical and in-person claims have different owner conventions; an ambiguous linked claim is rejected. Standalone legacy claims with neither a linked blame nor snapshot parties retain owner access.

The specialized expert/registrar creation and capture workflows retain their existing role and initiator checks, including the reorganized flows that create a claim before blame completion. The user creation rule is not imposed on those specialized endpoints.

For V4/V5 FileMaker files, the FileReviewer must retrieve the precreated claim with GET /v4|v5/file-reviewer/blame-request-management/claim-id/:requestId. This lookup verifies organization, branch/location, configured Fanavaran expertise code, sealed-file status, and reviewer assignment. WAITING_FOR_FILE_REVIEWER is a valid blame status during this handoff and part selection; blame becomes COMPLETED later in the capture workflow. The reviewer acts for the beneficiary through the specialized claim endpoints and must never use ordinary-user claim creation. Manually marking blame complete does not make the reviewer a user beneficiary.

The user UI stores one active identity. Successful OTP or expert login clears the previous party's token, active case IDs, per-case claim caches, Redux case state, and query data. A legacy browser containing both token keys must log in again. Creation requests are deduplicated per identity and blame case, and a rejected request cannot enable the claim-entry button or borrow an unrelated claim ID. Responses arriving after an account switch cannot overwrite the new account's active claim.

Regression coverage: claim-beneficiary-access.spec.ts, request-management.user-progress.spec.ts, file-reviewer-claim-handoff.spec.ts, and ui-user/scripts/test-claim-session.cjs / test-claim-entry.cjs. The handoff tests exercise both V4/V5 controllers, third-party/body files, linked claim lookup, part selection while blame is waiting, and lookup authorization failures. The entry tests execute the shared UI's effect with the actual FileReviewer API adapter, checking role/version routing, errors, and stale responses after account/case changes. Run npm test -- --runInBand in api and npm run test:ui in each UI repository.