Auth moved to standalone controller outside Riverpod: - New AuthController runs in main() before runApp() - Handles callback, token exchange, and /auth/sync before app starts - If auth not ready (redirecting), app doesn't start at all - AuthProvider now just loads stored tokens (no async OIDC logic) - Fixes "Cannot use Ref after disposed" errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
33 lines
953 B
Dart
33 lines
953 B
Dart
import 'dart:developer' as developer;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'app.dart';
|
|
import 'core/auth/auth_controller.dart';
|
|
import 'core/config/url_strategy.dart';
|
|
import 'version.g.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// Use path-based URLs on web (no-op on mobile/desktop)
|
|
configureUrlStrategy();
|
|
|
|
developer.log(
|
|
'${AppVersion.name} v${AppVersion.fullVersion}',
|
|
name: 'tatlock_ui',
|
|
);
|
|
|
|
// Initialize auth before starting the app.
|
|
// This handles OIDC callback and silent auth on web.
|
|
// If it returns false, we're redirecting and shouldn't continue.
|
|
final authReady = await AuthController.initialize();
|
|
if (!authReady) {
|
|
developer.log('Auth redirecting, not starting app', name: 'tatlock_ui');
|
|
return; // Don't run the app - browser is redirecting
|
|
}
|
|
|
|
runApp(const ProviderScope(child: TatlockApp()));
|
|
}
|