@@ -135,25 +135,30 @@ GoRouter createRouter({
135135 appStatus == AppStatus .authenticated) {
136136 print (' Redirect Decision: User is $appStatus .' );
137137
138- final isLinkingContext =
139- currentUri .queryParameters['context' ] == 'linking' ;
138+ final isLinkingContext =
139+ state.uri .queryParameters['context' ] == 'linking' ;
140140
141- // If an authenticated/anonymous user is on any authentication-related path,
142- // redirect them to the feed, unless it's the base authentication path
143- // AND it's specifically for account linking.
144- if (currentLocation.startsWith (authenticationPath) &&
145- ! (currentLocation == authenticationPath && isLinkingContext)) {
141+ // If an authenticated/anonymous user is on any authentication-related path:
142+ if (currentLocation.startsWith (authenticationPath)) {
143+ // Allow navigation within auth paths if the linking context is active
144+ if (isLinkingContext) {
145+ print (
146+ ' Action: $appStatus user on auth path ($currentLocation ) with linking context. Allowing navigation.' ,
147+ );
148+ return null ;
149+ } else {
150+ // Redirect to feed if not in a linking context (e.g., user manually types /authentication)
151+ print (
152+ ' Action: $appStatus user trying to access an auth path ($currentLocation ) without linking context. Redirecting to $feedPath ' ,
153+ );
154+ return feedPath;
155+ }
156+ }
157+ // Allow access to other routes (non-auth paths)
146158 print (
147- ' Action: $ appStatus user trying to access an auth path. Redirecting to $ feedPath ' ,
159+ ' Action: Allowing navigation to $ currentLocation for $ appStatus user (non- auth path). ' ,
148160 );
149- return feedPath;
150- }
151-
152- // Allow access to other routes (only if not an auth path, or if it's the base auth path for linking)
153- print (
154- ' Action: Allowing navigation to $currentLocation for $appStatus user.' ,
155- );
156- return null ;
161+ return null ;
157162 }
158163
159164 // Fallback (should ideally not be reached if all statuses are handled)
@@ -733,7 +738,7 @@ GoRouter createRouter({
733738 .read<
734739 HtDataRepository <Headline >
735740 > (),
736- ),
741+ ),
737742 ),
738743 BlocProvider (
739744 create:
0 commit comments