---
phase: 01-authentication
plan: 04
type: execute
wave: 2
depends_on: ["01-01", "01-02"]
files_modified: ["lib/features/authentication/data/repositories/auth_repository_impl.dart", "lib/providers/auth_provider.dart"]
autonomous: true
user_setup: []
must_haves:
truths:
- "Auth repository implementation connects to Supabase"
- "Auth state changes trigger UI updates automatically"
- "Session persists across app restarts"
artifacts:
- path: "lib/features/authentication/data/repositories/auth_repository_impl.dart"
provides: "Supabase auth implementation"
min_lines: 50
- path: "lib/providers/auth_provider.dart"
provides: "Global auth state management"
min_lines: 35
key_links:
- from: "lib/providers/auth_provider.dart"
to: "lib/features/authentication/data/repositories/auth_repository_impl.dart"
via: "dependency injection"
pattern: "AuthRepository|_authRepository"
- from: "lib/features/authentication/data/repositories/auth_repository_impl.dart"
to: "supabase.auth"
via: "Supabase client usage"
pattern: "supabase\\.auth\\."
---
Implement authentication repository and state management.
Purpose: Connect UI components to Supabase authentication and manage auth state globally.
Output: Working authentication system with session persistence and state management.
@~/.opencode/get-shit-done/workflows/execute-plan.md
@~/.opencode/get-shit-done/templates/summary.md
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/01-authentication/01-RESEARCH.md
Implement AuthRepository with Supabase
lib/features/authentication/data/repositories/auth_repository_impl.dart
Create AuthRepositoryImpl class that:
1. Implements AuthRepository interface from plan 02
2. Uses supabase.auth for all operations:
- signUp() with email/password, handles AuthResponse
- signIn() with email/password, handles AuthResponse
- signOut() to clear session
- resetPassword() with email and redirect URL
- getCurrentUser() from supabase.auth.currentUser
- authStateChanges() stream from onAuthStateChange
3. Converts Supabase errors to custom exceptions
4. Maps User to AuthUser model
5. Includes proper null safety handling
6. Has comprehensive error handling
7. Follows repository pattern correctly
8. Uses proper async/await patterns
Repository implementation connects to Supabase and handles all auth operations without throwing unhandled exceptions
Complete Supabase authentication repository ready for integration with state management
Create AuthProvider for state management
lib/providers/auth_provider.dart
Create AuthProvider class that:
1. Extends ChangeNotifier or uses Riverpod
2. Depends on AuthRepository (injection)
3. Manages auth state (User?, loading, error)
4. Listens to repository.authStateChanges() stream
5. Provides methods:
- signUp(String email, String password)
- signIn(String email, String password)
- signOut()
- resetPassword(String email)
6. Handles loading states and errors
7. Updates UI state automatically
8. Properly disposes of stream subscriptions
9. Has current User? getter
10. Includes proper error propagation
AuthProvider updates state correctly when auth events occur and maintains loading/error states properly
Global auth state management that automatically responds to authentication changes
1. Authentication repository successfully connects to Supabase and handles all auth methods
2. State management responds correctly to auth state changes
3. Session persistence works across app restarts
4. Error handling provides user-friendly feedback
5. Loading states work properly during authentication operations
Complete authentication repository and state management system ready for navigation integration.