Table of Contents
01 — Account access, onboarding and sign-in
Technical reference. For task-based help, see the corresponding user guide.
Documentation status: complete for the current implementation
Reviewed: 2026-07-21
Primary users: visitors, family members and coaches
Surfaces: mobile web app, coach admin portal and platform API
Purpose
This feature takes a person from first launch to the correct authenticated workspace. It explains the product before registration, creates either a family or coach identity, restores existing sessions, supports password recovery, and prevents a signed-in user from entering a workspace their role cannot use.
Supabase Auth issues the identity and session token. The platform API then resolves that identity to the trusted Littles Baby Tracker user, roles and capabilities. Client-side routing improves the experience, but it is not the authorization boundary.
User outcomes
| User | Outcome |
|---|---|
| New family member | Understand the app, create a family account, and arrive at the family home. |
| New coach | Create a coach account and arrive at the coach workspace. Commercial access is handled by Feature 04. |
| Returning family or coach | Sign in, restore the last valid session, and return to a safe requested route or the correct default home. |
| User who forgot a password | Request a time-limited recovery email and set a replacement password. |
| Migrated user | Upgrade a legacy password or claim a migrated identity without creating a duplicate product profile. |
| Coach portal user | Enter only when the platform resolves a coach role; receive a clear blocked, retry or redirect state otherwise. |
Entry points
| Surface | Route | Function |
|---|---|---|
| Mobile | /onboarding | Three-slide introduction covering changing, sleep and feeding. |
| Mobile | /welcome | Choose Create Account or Log In. |
| Mobile | /register | Choose Family or Coach. |
| Mobile | /family/register | Family email/password registration. |
| Mobile | /coach/register | Coach email/password registration. |
| Mobile | /login | Shared family/coach sign-in, password reset and repeated-failure help. |
| Mobile | /auth/callback | Completes an authentication callback and migrated-identity claim flow. |
| Mobile | /change-password | Signed-in password change or recovery callback. |
| Coach portal | /login | Coach email/password sign-in and reset request. |
| Coach portal | /auth/callback | Completes the password/OAuth callback and resumes a safe coach route. |
| Coach portal | /change-password-recovery | Sets and confirms a replacement password. |
| Coach portal | /auth/view-as | Exchanges a short-lived owner-issued view-as token for a visibly marked coach session. |
Functional flow
1. First launch and role choice
- The mobile introduction is swipeable and also supports explicit next-step buttons and progress dots.
- Reduced-motion preference is respected when moving between slides.
- The welcome screen separates registration from login.
- Registration asks whether the person is a Family user who tracks a baby or a Coach who supports families.
- A safe
nextparameter is preserved through login or registration only when it is an internal path beginning with/.
2. Family registration
- The form collects full name, email and password.
- Terms and Conditions acceptance and Privacy Policy acknowledgement are mandatory.
- Optional hints and tips, app-update/new-feature, and promotions preferences are collected independently and default off.
- Supabase creates the auth identity. If email confirmation is required and no session is returned, the app shows a confirmation state instead of attempting product onboarding.
- Once authenticated,
POST /auth/onboard-familycreates the platform family profile, applies the device timezone when available, and returns the trusted session context. - The default destination is
/family, unless a safe invite or other internal continuation route was supplied.
3. Coach registration
- The form collects coach name, email and password and displays an optional practice-name field.
- Terms and Conditions, Privacy Policy, and the separate Coach Terms of Use are all mandatory.
POST /auth/onboard-coachcreates the coach profile and independent practice context, then returns the trusted session.- The default destination is
/coach. - Registration does not itself grant a paid client-sharing entitlement; subscription and capacity gates are documented in Feature 04.
Current implementation note: the mobile form displays an optional practice-name field, but the registration intent currently forwards the coach name and communication preferences, not that field. Practice/business naming is available after sign-in in Feature 23.
4. Sign-in and session restoration
- Mobile and coach portal both support email/password sign-in.
- The mobile app first attempts ordinary Supabase sign-in. On an invalid-password response it may attempt the one-time legacy password upgrade, then retries sign-in.
- On app start, stored auth state is restored, refreshed when necessary, and resolved through
GET /auth/me. /auth/mereturns eitherauthenticatedwith a session oronboardingNeededwith no product session. It also carries server capability state used by rollout-gated features.- The mobile default route follows the actor's available roles and preferred context. A coach-only actor enters
/coach; a normal family actor enters/family. - Logout clears local product state and signs out the local Supabase session. The platform does not rely on a client-side role check to protect data.
5. Coach portal role gate
The coach portal has no registration screen. A coach account is created through the mobile registration journey or an approved administrative workflow, then signs in here.
After authentication, the portal resolves /auth/me and presents a deliberate state:
- Authenticated coach: continue to the requested safe coach route.
- Onboarding needed: block the portal because the auth identity has no platform profile.
- Family-only actor: deny the coach dashboard.
- Pure super-admin: direct the user to the separate owner portal.
- Backend unavailable: explain that sign-in succeeded but account lookup failed, with retry and login actions.
- Invalid or expired authentication: return to login.
- Owner view-as: show the delegated-session banner and enforce the platform's read-only restrictions.
6. Password recovery and change
- From mobile login, Forgot password? requires an email and calls the public platform reset endpoint. The recovery email returns through the platform's mobile recovery bridge so a new password can be set without storing credentials in the native wrapper.
- From coach portal login, Supabase sends a reset email whose callback resumes at
/change-password-recovery. - Replacement passwords require at least eight characters and matching confirmation.
- A signed-in mobile user can change a password from account settings using current, new and confirmation fields.
- Reset submission reports the same success shape regardless of account-discovery details; rate limiting is enforced server-side.
7. Repeated login trouble and migrated accounts
- After two failed mobile login attempts, the user can open a login-help form.
- The form requires a valid email and 5–2,000 characters of detail. Device/app context and the failed-attempt count may accompany the request.
- Legacy Firebase password credentials are consumed through the dedicated upgrade route and are not a second long-term login system.
- Migrated Apple identities can be claimed by a signed-in identity. A failed match signs the temporary session out and advises the user to use email/password or reset the password.
Current social sign-in status
Apple native/OAuth callback and migrated-identity handling are implemented in the mobile app, but the social sign-in controls are currently hidden by SHOW_SOCIAL_SIGN_IN = false. Google is also hidden. The current reachable, promoted sign-in method is email and password.
Validation and user-visible states
| State | Expected behavior |
|---|---|
| Loading or token refresh | Keep protected content hidden and show a focused progress state. |
| Email confirmation required | Explain that the user must open the confirmation email before signing in. |
| Invalid credentials | Show non-technical corrective copy; do not expose account internals. |
| Account setup failed after sign-in | Return to a recoverable signed-out state without leaving a partial workspace visible. |
| Callback failure | Offer a return to login. Migrated-identity failure gives the email/password recovery path. |
| Network/API timeout | Explain the connectivity problem and allow retry. |
| Role mismatch | Deny the wrong product surface and direct the actor to the correct portal where applicable. |
| Password reset throttled | Return a retry-later message. |
Platform API contract
| Method and path | Role in this feature | Authentication |
|---|---|---|
GET /auth/me | Resolve onboarding state, actor, roles and capabilities. | Supabase identity required |
POST /auth/onboard-family | Create the family product profile after auth registration. | Supabase identity required |
POST /auth/onboard-coach | Create the coach profile and independent practice context. | Supabase identity required |
POST /auth/claim-migrated-identity | Attach a migrated product identity to the signed-in auth user. | Supabase identity required |
POST /auth/legacy-password/upgrade | One-time legacy password migration before sign-in retry. | Public, schema validated and rate limited |
POST /auth/login-support | Submit repeated-login assistance details. | Public, schema validated and rate limited |
POST /auth/password-reset | Send a recovery email through the configured auth administrator. | Public, schema validated and rate limited |
Profile editing, communication-preference changes, self-family enablement and deletion are related account operations, but their full behavior belongs to Feature 02 and Feature 24.
Authorization and privacy rules
- Supabase Auth is used for identity and JWT issuance only. Trusted tenant data and authorization are resolved by the platform API.
- Family, coach and super-admin roles are explicit booleans in the session contract; a user may be dual-role.
- A client route never grants record access. Later family and coach operations still require their own subject and assignment checks.
- Owner view-as is a synthetic, expiring session and is enforced read-only by the platform for normal data mutations.
- Password reset, login support and legacy upgrade endpoints are rate limited. Login-support details are length-limited and telemetry avoids sensitive auth fields.
- The native wrapper receives only minimal runtime information and does not store Supabase tokens.
Acceptance checklist
- A new family can register, satisfy required consent, complete platform onboarding and reach
/family. - A new coach can register, satisfy coach-specific consent, complete onboarding and reach
/coach. - A returning user reaches the correct role-aware home and a safe internal
nextroute is preserved. - Email-confirmation, invalid-credential, timeout and API-lookup failures do not reveal protected screens.
- Mobile and coach portal recovery links set an eight-character-or-longer matching password.
- Family-only users cannot enter the coach portal; pure super-admins are directed to the owner portal.
- Public recovery/support endpoints remain schema validated and rate limited.
Source evidence
Mobile web
mobile-web/src/routes/WelcomeFlow.tsxmobile-web/src/routes/AuthScreen.tsxmobile-web/src/routes/AuthCallbackScreen.tsxmobile-web/src/routes/ChangePasswordScreen.tsxmobile-web/src/App.tsxmobile-web/src/api/supabase-auth.tsmobile-web/src/api/client.ts
Coach portal
admin-web/src/routes/AuthScreen.tsxadmin-web/src/routes/AuthCallbackScreen.tsxadmin-web/src/routes/PasswordRecoveryScreen.tsxadmin-web/src/App.tsxadmin-web/src/api/supabase-auth.ts
Platform and contracts
platform/apps/api/src/routes/auth-routes.tsplatform/apps/api/src/routes/mobile-web-auth-routes.tsplatform/apps/api/src/services/authorization-service.tsplatform/packages/shared/src/auth.tsplatform/packages/shared/src/access.tsplatform/packages/shared/src/communication-preferences.tsplatform/docs/multi-tenancy/05-development-plan.md
