@@ -87,6 +87,15 @@ GoRouter createRouter({required ValueNotifier<AppStatus> authStatusNotifier}) {
87
87
else if (appStatus == AppStatus .anonymous) {
88
88
print (' Redirect Decision: User is ANONYMOUS.' );
89
89
90
+ // Define search and account paths for clarity
91
+ const searchPath = Routes .search; // '/search'
92
+ const accountPath = Routes .account; // '/account'
93
+
94
+ // Helper booleans for search and account sections
95
+ final isGoingToSearch = currentLocation.startsWith (searchPath);
96
+ final isGoingToAccount = currentLocation.startsWith (accountPath);
97
+
98
+
90
99
// **Sub-Case 2.1: Navigating to the BASE Authentication Path (`/authentication`)**
91
100
if (isGoingToBaseAuthPath) {
92
101
// Allow access ONLY if they are explicitly starting the linking flow
@@ -115,15 +124,15 @@ GoRouter createRouter({required ValueNotifier<AppStatus> authStatusNotifier}) {
115
124
);
116
125
return null ; // Allow access
117
126
}
118
- // **Sub-Case 2.3: Navigating Within the Headlines Feed Section **
119
- // Allow anonymous users to access the main content feed and its sub-routes (like account) .
120
- else if (isGoingToFeed) {
127
+ // **Sub-Case 2.3: Navigating Within the Main App Sections ( Feed, Search, Account) **
128
+ // Allow anonymous users to access the main content sections and their sub-routes.
129
+ else if (isGoingToFeed || isGoingToSearch || isGoingToAccount ) { // Added checks for search and account
121
130
print (
122
- ' Action: Allowing navigation within feed section ($currentLocation ).' ,
131
+ ' Action: Allowing navigation within main app section ($currentLocation ).' , // Updated log message
123
132
);
124
133
return null ; // Allow access
125
134
}
126
- // **Sub-Case 2.4: Fallback for Unexpected Paths**
135
+ // **Sub-Case 2.4: Fallback for Unexpected Paths** // Now correctly handles only truly unexpected paths
127
136
// If an anonymous user tries to navigate anywhere else unexpected,
128
137
// redirect them to the main content feed as a safe default.
129
138
else {
0 commit comments