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({
149
149
print (' Debug: isLinkingPathSegmentPresent: $isLinkingPathSegmentPresent ' );
150
150
print (' Debug: isAnyLinkingContext evaluated to: $isAnyLinkingContext ' );
151
151
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.
153
162
if (isAnyLinkingContext) {
154
163
print (
155
- ' Action: $ appStatus user on auth linking path ($currentLocation ). Allowing navigation.' ,
164
+ ' Action: Anonymous user on auth linking path ($currentLocation ). Allowing navigation.' ,
156
165
);
157
166
return null ;
158
167
} else {
159
- // Redirect to feed if not in a linking context (e.g., user manually types /authentication)
160
168
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 ' ,
162
170
);
163
171
return feedPath;
164
172
}
You can’t perform that action at this time.
0 commit comments