Login scenarios, password reset flow, deep links, and offline mode
| Scenario |
User Experience |
Backend Process |
| Valid Credentials |
Immediate login and redirect to home |
Auth token created, user profile loaded |
| Invalid Email |
Error: “Please enter a valid email” |
Validation fails client-side |
| Wrong Password |
Error: “Invalid login credentials” |
Supabase auth rejection |
| Unconfirmed Email |
Error: “Email not confirmed” |
Auth blocked until confirmation |
| No Internet |
Uses cached profile if available |
Offline mode activated |
| Unlinked Auth User |
Signup appears to fail initially |
Automatic cleanup then fresh signup succeeds |
| Unlinked User Profile |
Signup succeeds normally |
Self-healing: updates existing profile with new auth ID |
- Tracks last authenticated user ID and timestamp
- Ignores duplicate auth changes within 2 seconds
- Prevents multiple navigation attempts
- Ensures stable authentication flow
- Email Verification: System checks if email exists in database
- Send Reset Link: If email exists, sends password reset email
- User Clicks Link: Opens reset form in browser
- New Password Entry: User enters new password (min 6 characters)
- Password Update: Updates in
auth.users table
- Auto Login: User automatically signed in with new password
| Error |
Message |
| Email not found |
“This account is not currently registered” |
| Rate limit exceeded |
“Too many requests, please wait 60 seconds” |
| Same password |
“New password must be different from old password” |
| Platform |
Deep Link Format |
Usage |
| Android |
io.lucidflow://login-callback |
Email confirmation redirect |
| iOS (future) |
io.lucidflow://login-callback |
Email confirmation redirect |
| Web (future) |
https://hypno-56118.web.app/ |
Standard web URLs |
When the device has no internet connection:
Available offline:
- Access previously loaded user profile
- Play downloaded audio content
- View course information
Requires internet:
- New purchases
- Account settings changes
- Sync operations
- New user completes sign-up
is_new_user flag set to true
- Free trial plan automatically assigned
- Welcome dialog shown on first login
- Onboarding guide available
| File |
Purpose |
lib/screens/login_screen.dart |
Login UI and form validation |
lib/screens/forgot_password_screen.dart |
Password reset UI and flow |
lib/providers/user_provider.dart |
Auth logic, profile caching |
lib/models/user_profile.dart |
User data model and JSON serialization |