Skip to content

Commit 06be069

Browse files
committed
fix: routing error
1 parent 10bb135 commit 06be069

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/router/router.dart

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ GoRouter createRouter({required ValueNotifier<AppStatus> authStatusNotifier}) {
8787
else if (appStatus == AppStatus.anonymous) {
8888
print(' Redirect Decision: User is ANONYMOUS.');
8989

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+
9099
// **Sub-Case 2.1: Navigating to the BASE Authentication Path (`/authentication`)**
91100
if (isGoingToBaseAuthPath) {
92101
// Allow access ONLY if they are explicitly starting the linking flow
@@ -115,15 +124,15 @@ GoRouter createRouter({required ValueNotifier<AppStatus> authStatusNotifier}) {
115124
);
116125
return null; // Allow access
117126
}
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
121130
print(
122-
' Action: Allowing navigation within feed section ($currentLocation).',
131+
' Action: Allowing navigation within main app section ($currentLocation).', // Updated log message
123132
);
124133
return null; // Allow access
125134
}
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
127136
// If an anonymous user tries to navigate anywhere else unexpected,
128137
// redirect them to the main content feed as a safe default.
129138
else {

0 commit comments

Comments
 (0)