Skip to content

Worker and subcontractor access

Workers receive work through personal assignments. Subcontractors receive work through commitments assigned to their company. These relationships establish resource scope; publication determines which instructions or scheduled passes a portal presents. Permission to submit, complete or review work has additional conditions specific to the operation.

The role surfaces use a verified identity and active company. Browser guards guide navigation. The API and database enforce their own predicates, as described in capabilities and resource access.

Audience Entry conditions Resource relationship Publication or action condition
Worker _require_worker requires an active company and an active, non-deleted worker person for the login in that company. A live project_assignments row, or a live work_order_assignments row whose non-deleted order belongs to the requested project/company. Delivery reads require released work; exact order assignment limits order instructions and completion.
Subcontractor dashboard Authenticated caller, active company of type subcontractor. Invitations/applications belong to that company; commitments name it in fk_executor_tenant. Request visibility, offer version and response permissions differ from commitment access.
Direct UE work room or dialogue Active company must be the commitment’s principal or executor. Requested commitment must exist and be non-deleted. The payload also verifies project ownership by the principal. Principal callers additionally require staff membership and projects:read. Executor access is company-scoped, without that principal capability check.
Principal review Active-company staff and the relevant capability. The reviewed submission/time record must belong to that principal’s review context. projects:read opens the review queue; projects:write permits decisions. Submitting evidence does not approve it.

The worker browser guard additionally excludes subcontractor companies. The worker API helper checks the worker person but does not repeat that tenant-type exclusion. Conversely, the direct UE room does not apply the dashboard’s subcontractor-type check to the executor branch. Do not infer identical server decisions from where navigation sends a user.

/worker fetches GET /api/worker/day. The compatibility my-projects endpoint uses the same projection. Direct project detail uses GET /api/worker/projects/{pk}/detail.

The day projection derives projects from exact assigned work orders published with is_published_to_worker, or the person’s own published schedule rows with a current assignment. A schedule tied to an order requires that exact order assignment. A project-level schedule requires a live project relationship, which can also be derived from an assigned order. A booking alone grants no access.

An order and a scheduled pass can be published independently. A published pass can therefore expose its permitted scheduling context while an unpublished order’s identifier and instructions remain hidden. Detail returns only exact assigned, published orders and selected delivery fields: instructions, quantities, checklists and validated room/surface context. It does not return quote prices or internal cost fields from the source records.

Worker files use separate, unrevoked work_order_file_links for the exact released order. The loader checks project/company, verified customer-upload metadata, MIME type and canonical object path before issuing a short-lived link. Customer file visibility is not worker publication. Checklist progress updates use the browser’s Supabase client under RLS; policies require published exact assignment, and the update trigger limits workers to progress fields and requires the correct stored photo for photo-required completion.

Publication is not a universal condition on every worker API operation:

  • Completing an order requires exact live assignment, a published non-deleted order in the company, completed checklist items and any required photos.
  • Creating time requires live project scope, exact assignment if an order is supplied, a valid report date and a completed start check or staff exception. The handler sets person/company from the caller and status to pending. It does not additionally require the order’s publication flag.
  • Worker dialogue reads, sends and attachment requests require live effective project assignment. They use the worker-project conversation, separately from customer and internal conversations. They do not use the delivery-publication gate. See conversation audiences.

Removing the last order assignment removes its derived project authority. An independent direct project assignment can still preserve project-level actions; it does not grant every order’s instructions. Withdrawing publication hides the delivery but does not itself revoke that separate assignment relationship.

An open clock has a recovery exception: the day/detail projection retains a neutral entry when no released work remains or the project is soft-deleted. Its title is “Pågående arbetspass”, with no released orders, address or schedules. Clock-out requires an existing open clock and a project in the same company, rather than current assignment or publication. Starting a new clock requires both, and the company’s clock setting. Own time-report history remains readable by person and company without a fresh assignment check; that endpoint includes linked project labels. Historical access therefore differs from new-work authority.

The UE dashboard lists open public requests and this company’s current-version invitations. Eligible historical invitations remain visible after award, closure or cancellation. Returned offer snapshots contain the request’s scope, proposed period and compensation terms; they are not the customer’s quote prices. The subcontractor’s applications are selected by executor company.

Responding requires applications:write, a subcontractor company and an actor person. The service-role-only response transaction validates the active person, current offer/invitation, request state and deadline. A positive response is an application, not an award. Principal award requires applications:moderate, the principal’s listing/project scope, eligible executor and an actor; the award RPC checks active, non-worker principal staff, current offer and winner state and creates or recovers the commitment. Its single-winner transaction is source-reviewed here, not executed. The subcontracting workflow owns the wider lifecycle.

/ue/work/:pkCommitment loads GET /api/ue/portal/assigned-work/{pk_commitment}. A principal can open this room without switching into the executor company. If the principal’s general UE dashboard request is refused but the direct room succeeds, the browser retains that permitted room. The ordinary dashboard lists commitments assigned to the executor company.

The room builder verifies that the project belongs to the commitment’s principal. An order-scoped request limits the room to that order, even if its general UE visibility flag is false. A project-scoped commitment instead uses is_visible_to_ue for orders. Scheduled passes require is_published_to_ue, the exact commitment and a visible/scoped order. Internal project and order planning dates are omitted; the commitment period and permitted passes remain distinct. Submission photos and time reports are grouped by exact commitment rather than guessed from the project alone.

For new submissions and time, the API requires a subcontractor company and re-fetches the commitment with fk_executor_tenant equal to the caller’s company. An optional order must belong to the project and be UE-visible or the explicitly scoped order. Time additionally requires an eligible worker in the executor company; the caller does not need to be that worker. An omitted order is permitted at commitment level. Submissions are stored under the principal company; time under the executor, with head-company/project and commitment references. Both enter pending review.

For worker Alex in company A, a live assignment to published order W makes its project discoverable. Opening the project route sends the bearer token; the API loads Alex’s worker person, verifies project scope and returns only released delivery. Alex can submit time for W after the start check. If W is reassigned and Alex has no remaining project relationship, the same time/message requests are refused before inserting the business record. Another company’s project is also refused after resource scope is checked.

For executor company E, commitment C names E and a project owned by principal A. The UE room route returns C’s scoped execution payload. A request from unrelated company F receives 404; it cannot upload a submission against C because the executor-scoped commitment lookup fails before photo upload. Principal staff can open the room with projects:read; principal non-staff receive 403. Revoking the principal’s read role prevents room/dialogue effects on subsequent checked requests; executor authority still follows its separate commitment relationship.

flowchart TD
  I[Verified identity and active company] --> W[Worker person]
  I --> U[Executor company or principal staff]
  W --> A[Live project or exact order assignment]
  A --> P[Published order or personal pass]
  P --> D[Worker delivery projection]
  A --> T[Time and worker dialogue: operation-specific checks]
  U --> C[Requested commitment and participating company]
  C --> S[Principal project ownership and request scope]
  S --> E[UE room and permitted passes]
  C --> R[Executor submission or principal review checks]
Worker delivery and subcontractor work use different relationships and publication checks.

The following source differences prevent a blanket claim that API, browser and database access are equivalent:

  • Selected worker API reads require the live worker relationship but no projects:read_own or work_orders:read_own lookup. The corresponding RLS read policies add these capabilities and the publication helpers. The later schedule policy checks exact order assignment for order-linked passes.
  • UE project-file loading checks project/company, non-deleted metadata and canonical path, but does not filter customer visibility, content validity or worker file links. It returns project-wide file rows, including storage paths, even for an order-scoped room. This is broader than worker/customer publication; do not describe all UE files as explicitly published to that audience.
  • The inspected commitment loaders exclude deleted records but do not reject a closed status. Closure alone is not a general access-revocation rule in these handlers. Complete lifecycle policy needs a separate decision and verification.
  • The submission route validates executor commitment before uploading photos, but checks optional order scope inside the subsequent insert helper. An invalid order in an otherwise admitted commitment can therefore be rejected after an upload. This review does not establish that every refusal precedes every effect.

The focused run passed 200 backend tests covering worker identity, assignment, publication/recovery, selected writes, UE scope, invitation guards and review. It also passed 14 frontend tests for worker lists/denials and UE direct links. The PR records exact selections. Worker route tests substitute authenticated identity and use filtering clients; UE tests mix direct handler/helper calls and route checks with substituted identity, database, Storage, notification and RPC effects. They are not one end-to-end browser/Auth/database run.

The database assignment/publication, file-link, conversation, offer and award tests were inspected, not executed. This review establishes neither current deployment nor exhaustive company/role transitions, issued-link revocation, UE browser session races or transactional/concurrent award outcomes. Execution and review and publication ownership remain separate from these access mechanisms. Remaining customer discovery and resource-policy gaps remain recorded in their owning access articles.