From 1b249e34b0d3a04babb9ab8562030c830683e2d3 Mon Sep 17 00:00:00 2001 From: ramadhan sjamsani Date: Thu, 9 Apr 2026 14:38:48 +0800 Subject: [PATCH] Fix router redirect breaking OTP flow on both apps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AsyncLoading during OTP request was redirecting from /login to /splash, bouncing users back to login. Now auth routes stay put during loading — only redirect to splash from non-auth routes (initial app startup). Co-Authored-By: Claude Opus 4.6 (1M context) --- client_app/lib/router.dart | 7 +++++-- mitra_app/lib/router.dart | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/client_app/lib/router.dart b/client_app/lib/router.dart index a016996..8282319 100644 --- a/client_app/lib/router.dart +++ b/client_app/lib/router.dart @@ -38,8 +38,11 @@ GoRouter buildRouter(Ref ref) { final isAuthRoute = state.matchedLocation.startsWith('/auth') || state.matchedLocation == '/welcome'; - // Show splash while loading - if (authState is AsyncLoading) return isSplash ? null : '/splash'; + // Show splash only during initial load — don't redirect away from auth routes + if (authState is AsyncLoading) { + if (isSplash || isAuthRoute) return null; + return '/splash'; + } final data = authState.valueOrNull; if (data == null) { diff --git a/mitra_app/lib/router.dart b/mitra_app/lib/router.dart index a48fb4b..b1157bd 100644 --- a/mitra_app/lib/router.dart +++ b/mitra_app/lib/router.dart @@ -33,8 +33,11 @@ GoRouter buildRouter(Ref ref) { final isAuthRoute = state.matchedLocation.startsWith('/login') || state.matchedLocation.startsWith('/otp'); - // Show splash while loading - if (authState is AsyncLoading) return isSplash ? null : '/splash'; + // Show splash only during initial load — don't redirect away from auth routes + if (authState is AsyncLoading) { + if (isSplash || isAuthRoute) return null; + return '/splash'; + } final data = authState.valueOrNull; if (data == null) {