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
usersrow.
Happy path
Step by step
- Owner opens the signup page (SPA) with the clinic's
tenant_idpre-filled in a hidden field (from the invite link, or chosen in a clinic dropdown). - Enters name, email, phone, password, password confirmation.
- SPA calls
POST /api/v1/auth/owner/register. - Backend inserts:
- A
Userwithaccount_type = 'owner'andcurrent_tenant_id = <tenant_id>. - A
Clientwithtenant_id,owner_user_id, a copy of the full name, phone and email,status = 'active'.
- A
- Backend returns
{ user, client_id }. (A Sanctum token will be issued once the login endpoint is updated to emit one.) - SPA saves the session (same localStorage keys as staff login).
- 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
| Table | Row |
|---|---|
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/onboardwith theirclient_id. - View their pets (
/owner/me/pets). - View their appointments (
/owner/me/appointments). - View their invoices (
/owner/me/invoices).
Edge cases
- Unknown tenant —
tenant_id: exists:tenants,idvalidation fails with 422. - Duplicate email —
email: unique:usersvalidation fails with 422. - Password mismatch —
password: confirmedfails with 422 referencingpassword_confirmation.
Future improvements
- Email verification —
users.email_verified_atexists but isn't exercised in the owner flow yet. Hooking Laravel'sSendEmailVerificationNotificationwould add email confirmation. - Invite-only mode — some clinics will want to pre-create
Clientrows and send one-time signup tokens. The schema supports it; the flow needs a bit of glue.