Skip to main content

Workflow: Pet Owner Registration

How a pet owner self-registers for a clinic's portal.

Actors

  • Pet Owner (new external user)

Preconditions

  • The clinic exists and is active.
  • The owner has the clinic's tenant_id (typically shared via a signup link).
  • The owner's email is not already used by any users row.

Happy path

Step by step

  1. Owner opens the signup page (SPA) with the clinic's tenant_id pre-filled in a hidden field (from the invite link, or chosen in a clinic dropdown).
  2. Enters name, email, phone, password, password confirmation.
  3. SPA calls POST /api/v1/auth/owner/register.
  4. Backend inserts:
    • A User with account_type = 'owner' and current_tenant_id = <tenant_id>.
    • A Client with tenant_id, owner_user_id, a copy of the full name, phone and email, status = 'active'.
  5. Backend returns { user, client_id }. (A Sanctum token will be issued once the login endpoint is updated to emit one.)
  6. SPA saves the session (same localStorage keys as staff login).
  7. Owner lands on the owner portal — a stripped-down SPA showing only their pets, appointments and invoices via /api/v1/owner/me/*.

What's created

TableRow
users{ account_type='owner', current_tenant_id=<tenant_id>, name, email, phone, password=hashed }
clients{ tenant_id, owner_user_id=<new user id>, full_name, email, phone, status='active' }

No rows in pets yet — the owner must either add a pet in the SPA or ask the clinic to register one.

What an owner can do next

  • Add a pet via POST /api/v1/tenant/{tenant}/patients/onboard with their client_id.
  • View their pets (/owner/me/pets).
  • View their appointments (/owner/me/appointments).
  • View their invoices (/owner/me/invoices).

Edge cases

  • Unknown tenanttenant_id: exists:tenants,id validation fails with 422.
  • Duplicate emailemail: unique:users validation fails with 422.
  • Password mismatchpassword: confirmed fails with 422 referencing password_confirmation.

Future improvements

  • Email verificationusers.email_verified_at exists but isn't exercised in the owner flow yet. Hooking Laravel's SendEmailVerificationNotification would add email confirmation.
  • Invite-only mode — some clinics will want to pre-create Client rows and send one-time signup tokens. The schema supports it; the flow needs a bit of glue.