Phase 1 scaffold: auth for all apps
- Backend: Fastify with two listeners (public + internal), routes, services, DB migration + seed - client_app: Flutter with BLoC, all auth screens (welcome, display name, register, OTP, force-register) - mitra_app: Flutter with BLoC, OTP-only login - control_center: React + Vite, email/password login, mitra/user management, anonymity settings - Docs: phase1 plan, API contract, client app mockup - CLAUDE.md and shared memory for all subprojects Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
35
client_app/lib/router.dart
Normal file
35
client_app/lib/router.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'core/auth/auth_bloc.dart';
|
||||
import 'features/auth/screens/welcome_screen.dart';
|
||||
import 'features/auth/screens/display_name_screen.dart';
|
||||
import 'features/auth/screens/register_screen.dart';
|
||||
import 'features/auth/screens/otp_screen.dart';
|
||||
import 'features/auth/screens/force_register_screen.dart';
|
||||
import 'features/home/home_screen.dart';
|
||||
|
||||
GoRouter buildRouter(AuthBloc authBloc) {
|
||||
return GoRouter(
|
||||
initialLocation: '/welcome',
|
||||
redirect: (context, state) {
|
||||
final authState = authBloc.state;
|
||||
final isAuthRoute = state.matchedLocation.startsWith('/auth') ||
|
||||
state.matchedLocation == '/welcome';
|
||||
|
||||
if (authState is AuthAuthenticated || authState is AuthAnonymous) {
|
||||
return isAuthRoute ? '/home' : null;
|
||||
}
|
||||
if (authState is AuthForceRegister) return '/auth/force-register';
|
||||
if (!isAuthRoute) return '/welcome';
|
||||
return null;
|
||||
},
|
||||
routes: [
|
||||
GoRoute(path: '/welcome', builder: (_, __) => const WelcomeScreen()),
|
||||
GoRoute(path: '/auth/display-name', builder: (_, __) => const DisplayNameScreen()),
|
||||
GoRoute(path: '/auth/register', builder: (_, __) => const RegisterScreen()),
|
||||
GoRoute(path: '/auth/otp', builder: (context, state) => OtpScreen(phone: state.extra as String)),
|
||||
GoRoute(path: '/auth/force-register', builder: (_, __) => const ForceRegisterScreen()),
|
||||
GoRoute(path: '/home', builder: (_, __) => const HomeScreen()),
|
||||
],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user