File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -149,16 +149,24 @@ GoRouter createRouter({
149149 print (' Debug: isLinkingPathSegmentPresent: $isLinkingPathSegmentPresent ' );
150150 print (' Debug: isAnyLinkingContext evaluated to: $isAnyLinkingContext ' );
151151
152- // Allow navigation within auth paths if any linking context is active
152+ // If the user is authenticated, always redirect away from auth paths.
153+ if (appStatus == AppStatus .authenticated) {
154+ print (
155+ ' Action: Authenticated user on auth path ($currentLocation ). Redirecting to $feedPath ' ,
156+ );
157+ return feedPath;
158+ }
159+
160+ // If the user is anonymous, allow navigation within auth paths if in a linking context.
161+ // Otherwise, redirect anonymous users trying to access non-linking auth paths to feed.
153162 if (isAnyLinkingContext) {
154163 print (
155- ' Action: $ appStatus user on auth linking path ($currentLocation ). Allowing navigation.' ,
164+ ' Action: Anonymous user on auth linking path ($currentLocation ). Allowing navigation.' ,
156165 );
157166 return null ;
158167 } else {
159- // Redirect to feed if not in a linking context (e.g., user manually types /authentication)
160168 print (
161- ' Action: $ appStatus user trying to access an auth path ($currentLocation ) without linking context . Redirecting to $feedPath ' ,
169+ ' Action: Anonymous user trying to access non-linking auth path ($currentLocation ). Redirecting to $feedPath ' ,
162170 );
163171 return feedPath;
164172 }
You can’t perform that action at this time.
0 commit comments