Files
yara724-api/docs/profile-panel-audit.md
T
SepehrYahyaee 2056412efe fix: harden profile updates and localize public errors in Persian
Preserve actor and user profile fields during partial updates and validate supported personal data.

Add Persian HTTP error handling, validation translations, regression tests, and audit documentation.
2026-11-04 12:03:04 +03:30

5.2 KiB
Raw Blame History

Profile panel review — 2026-11-04

Scope: the regular user account pages, the actor profiles reachable through user flows V2–V6, and the expert panel's account page/editor. This is a profile functionality and accessibility review, not an audit of every application workflow.

Plate management

Profile plate management remains retired. Neither panel exposes saved-plate management. POST /user/profile/plate and DELETE /user/profile/plate/:id remain absent from the API. Existing historical data is retained; accident inquiry plate entry is a separate capability and remains available.

Confirmed problems and fixes

Problem Fix
User GET responses omitted saved province/address. Return state and address in the public user profile.
User PATCH returned the pre-update document. Read and return the saved public profile after updating.
Birthday format differed between the picker, legacy stored data and documented API. Read legacy Jalali and Gregorian dates in the UI; submit Gregorian date-only strings. The API accepts legacy packed/separated Jalali input and validates before saving.
Gender labels were submitted in Persian despite the stored male/female contract. Normalize gender while preserving Persian UI labels.
User-panel experts were offered birthday/gender fields unsupported by their profile storage. Show supported actor name/contact/location fields instead.
File makers, file reviewers and call-center agents could read profiles but not save their personal details. Field experts could not save their location. Support personal profile updates for all corresponding actor roles.
Insurer profile lookup depended on the token username being an email. Resolve the authenticated insurer account by JWT subject when available.
Expert editor split names on spaces, discarded later surname words and initialized the landline as empty. Return explicit first/last names and phone; preserve all existing values.
Expert location selects did not initialize from the profile and could submit undefined location values. Bind saved names to form state and load cities for the selected province. Submit only changed fields.
Province/city lookup failures were silent; stale requests could replace a newer city's options. Provide recoverable errors and associate requests with the selected province; keep saved values.
Profile fetch failures looked like empty accounts, and save failures were only logged. Add loading/error/retry states, retain failed edits, and expose logout even when user profile loading fails.
The expert edit modal nested buttons around its form and lacked proper dialog focus behavior. Use the existing Radix dialog, associated input labels and error messages; restore focus to the edit button on close.
Updating the header name replaced other Redux login properties. Preserve the existing login state when updating the displayed name.
Actor PATCH returned the authentication document. Return the same public profile representation as GET, excluding passwords, OTPs, tokens and internal assignment fields.

Profile API contract

  • GET/PATCH /user/profile: authenticated user's personal details only; partial updates supported. Birth dates are Gregorian YYYY-MM-DD for new writes. User responses continue to omit saved plates.
  • GET/PATCH /actor/profile: public profile includes explicit firstName, lastName, phone, and editableFields. The UI uses editableFields to offer only supported controls.
  • Blame expert, damage expert, field expert, insurer, file maker, file reviewer and call center: name, mobile, landline, province, city and address.
  • Super admin: first and last names, matching its existing schema.
  • Legacy registrar: email, matching its existing schema.
  • Self-profile updates cannot alter role, tenant/branch assignments, national code, password or Fanavaran expert codes. Those management operations retain their separate existing APIs.
  • Validation is performed in profile services because the application does not enable a global validation pipe. Invalid types, invalid phone numbers/dates and unsupported fields are rejected before writing.

Verification

  • Backend regression checks cover each supported actor role, insurer lookup by subject, partial updates, missing accounts, malformed/privileged fields, public responses and user birthday/gender compatibility. Existing authentication-guard and API-route-contract tests are included.
  • User utility checks cover Gregorian/legacy Jalali dates, Persian digits, multiword names and distinct actor/user PATCH payloads. Existing user UI utility/workflow checks are retained.
  • Expert profile utility checks cover multiword names, landline preservation, partial changes and role-supported fields.
  • Local Firefox checks use mocked API data only: regular user save/reopen and failed-save recovery; V2/V3 field expert, V4 file maker, V5 file reviewer and V6 call center profile navigation/save; expert dialog save/reopen/error recovery, mobile overflow, Escape and focus restoration. Desktop and mobile viewport screenshots were inspected.
  • These checks do not modify production accounts and do not establish that every application page is free of bugs. Physical-device and screen-reader testing remain outside this review.