diff --git a/Applications/AdminUi/apps/admin_ui/lib/screens/splash_screen.dart b/Applications/AdminUi/apps/admin_ui/lib/screens/splash_screen.dart index 0f7a70c5a7..9e42ada9c6 100644 --- a/Applications/AdminUi/apps/admin_ui/lib/screens/splash_screen.dart +++ b/Applications/AdminUi/apps/admin_ui/lib/screens/splash_screen.dart @@ -45,23 +45,22 @@ class _SplashScreenState extends State { await GetIt.I.allReady(); final sp = await SharedPreferences.getInstance(); - if (!sp.containsKey('api_key')) return _navigate('/login'); + if (!sp.containsKey('api_key')) return _navigateToLogin(); final apiKey = sp.getString('api_key')!; const baseUrl = kIsWeb ? '' : String.fromEnvironment('base_url'); final isValid = await AdminApiClient.validateApiKey(baseUrl: baseUrl, apiKey: apiKey); - if (!isValid) return _navigate('/login'); + if (!isValid) return _navigateToLogin(); GetIt.I.registerSingleton(await AdminApiClient.create(baseUrl: baseUrl, apiKey: apiKey)); - return _navigate('/identities'); - } - void _navigate(String defaultRoute) { if (!mounted) return; if (widget.redirect != null) return context.go(Uri.decodeComponent(widget.redirect!)); - context.go(defaultRoute); + context.go('/identities'); } + + void _navigateToLogin() => context.go(widget.redirect != null ? '/login?redirect=${widget.redirect!}' : '/login'); }