Home ToS / Pending-Seller Bootstrap
presentation/home.dart · _checkInitialTos / _checkPendingSeller
Overview
Post-frame side-effects fired the first time HomeScreen mounts: re-check ToS consent (in case the version bumped while logged in), and re-route to /devenir-prestataire if a pending-seller flag is set.
User Flow
- WidgetsBinding.instance.addPostFrameCallback schedules the work after the first build.
- authStateProvider.notifier.refreshAuthState() reloads (isLoggedIn, role) from storage.
- _checkInitialTos calls TosApiService.getLatestTos + checkConsent; if not consented, context.goNamed(termsOfService).
- _checkPendingSeller reads AuthStorageService.isPendingSellerRegistration; if true, context.goNamed(devenirPrestataire).
Cases & Edge Cases
- Both checks early-return when isLoggedIn is false — guests don't touch /tos/latest at all.
- If both ToS-stale and pending-seller fire, ToS wins (it's checked first and context.goNamed is async-fire-and-forget).
- Errors are swallowed with a debugPrint — backend outage during ToS check leaves the user on /home rather than blocking them.
Code References
- lib/src/features/shared/home/presentation/home.dart:34 // post-frame callback
- lib/src/features/shared/home/presentation/home.dart:41 // _checkInitialTos
- lib/src/features/shared/home/presentation/home.dart:63 // _checkPendingSeller
- lib/src/features/shared/tos/data/tos_api_service.dart
API Calls
- GET
/store/tosno statusFetch the latest published ToS document (id, version, content URL).
Response{ id: string, version: string, contentUrl: string, ... } | nulllib/src/features/shared/home/presentation/home.dart // _checkInitialTos + lib/src/features/shared/tos/presentation/terms_of_service_screen.dartauth: customer. Wrapped in TosApiService.
- GET
/store/tos/consent?termsVersion=:vno statusCheck whether the current user has consented to a given ToS version.
RequestQuery: termsVersion=<string>
Response200 (consented)
Errors- ·404 — not yet consented
lib/src/features/shared/home/presentation/home.dart + lib/src/core/routing/app_router.dart // _verifyTosConsentauth: customer. Result is memoized at module scope to avoid redirect spam.
- POST
/store/tos/consentno statusRecord the user's consent to a ToS version.
Request{ termsVersion: string }Response200 (no body)
lib/src/features/shared/tos/presentation/terms_of_service_screen.dart // Accept buttonauth: customer.
Notes
Treat this as a redundant safety net — the GoRouter redirect is the primary gate. If you remove either check here, the redirect's memoization (_hasConsentedToS) must be invalidated on login.