Skip to content

Manager Invites

1. Purpose

Define how Manager access is granted to a Company, the membership model for Managers, and constraints around Company association.

Sources: Build Spec §3, §5.1, §5.2, Domain §1, §2, §3, API Conventions §5, §7, Architecture §3.

2. Scope

This spec covers Manager membership/access rules. It does not cover Passenger enrollment (see Enrollment Approval) or Driver account creation beyond role terminology boundaries.

3. Membership Model

  • Membership (company_members) links a User to one Company with role and status.
  • Membership role: manager | driver | passenger.
  • Membership status: pending | approved | rejected | suspended.
  • One company per user.
  • Managers and Drivers are free; Seats count only approved Passenger memberships.

4. Manager Access Rules

Rule Expected behavior
Company association A Manager belongs to exactly one Company through membership.
Role Manager membership uses role manager.
Access surface Managers operate Fleet Dashboard and company-scoped /company/* API routes.
Tenancy company_id is derived from authenticated membership; never client-supplied.
Cross-tenant Cross-tenant access returns 404.
Suspension A suspended Company blocks authenticated company routes with 403; suspended membership behavior must also block access as defined by implementation.

5. Invites and Creation

The preserved build spec indicates Manager/company setup occurs through platform/company onboarding flows and company operations. The current docs do not fully define a dedicated "Manager invite" endpoint or UI.

Known facts: - Company onboarding creates a Manager membership (Architecture §5). - Fleet Dashboard is company-facing operations surface for Managers. - Platform Admin manages companies in Filament.

Thin-source behavior (proposed, requires confirmation before implementation):

  • A Manager invite should create or target a User by phone and create a company_members row with role manager.
  • Invited Manager accepts by completing phone + OTP authentication.
  • Invite should be auditable (invited by, invited at, accepted at).
  • A user already belonging to another Company cannot be invited as Manager unless the one-company-per-user rule is explicitly changed (not currently allowed).

Open question: There is no explicit manager invite endpoint/flow in the current docs. The implementation slice must confirm whether Manager invites are required in the current product scope, and define the exact API/UI contract before coding.

6. Validation and Errors

  • Standard error shape: { "message": string, "errors"?: Record<string, string[]> }.
  • Attempting to create/approve a Manager membership that violates one-company-per-user must be rejected with 422 (or another documented 4xx) and clear message.
  • Unauthorized/forbidden/cross-tenant cases follow API conventions: 401/403/404 as applicable.

7. Tests

Minimum tests when a Manager invite/create slice is implemented:

  • Feature tests: authorized actor can create/invite Manager; invited Manager can authenticate and access /company/*.
  • One-company-per-user test: inviting/assigning a user already in another Company is rejected.
  • Tenancy test: Manager cannot access another Company's resources; 404.
  • Role test: Manager token can access allowed company routes and cannot access Platform Admin routes.
  • Suspension tests: suspended Company/membership blocks access appropriately.
  • Error-shape contract: all error responses follow standard shape.

8. Open Questions

  • Is a dedicated Manager invite flow in scope, or are Managers created only during onboarding/platform admin operations?
  • Who can invite Managers: existing Manager, Platform Admin, or both?
  • Invite delivery mechanism (SMS, in-app, link) and expiry.
  • Can a Company have multiple Managers? If yes, are there ownership/admin distinctions?
  • Membership status lifecycle for Managers (pending vs immediately approved).
  • How Manager removal/deactivation is represented (rejected, suspended, or deleted membership) and its audit requirements.