Skip to content

Commit 497e368

Browse files
committed
refactor(router): redirect from auth sub-routes
- Simplify auth path redirection logic - Clarify redirect conditions
1 parent b966daa commit 497e368

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

lib/router/router.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,18 @@ GoRouter createRouter({
138138
final isLinkingContext =
139139
currentUri.queryParameters['context'] == 'linking';
140140

141-
// If an authenticated/anonymous user tries to access the BASE /authentication path
142-
// AND it's NOT for account linking, redirect them to the feed.
143-
if (currentLocation == authenticationPath && !isLinkingContext) {
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)) {
144146
print(
145-
' Action: $appStatus user trying to access base auth path without linking context. Redirecting to $feedPath',
147+
' Action: $appStatus user trying to access an auth path. Redirecting to $feedPath',
146148
);
147149
return feedPath;
148150
}
149151

150-
// Allow access to other routes (including auth sub-routes if linking, or any other app route)
152+
// Allow access to other routes (only if not an auth path, or if it's the base auth path for linking)
151153
print(
152154
' Action: Allowing navigation to $currentLocation for $appStatus user.',
153155
);

pubspec.lock

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ packages:
8989
url: "https://pub.dev"
9090
source: hosted
9191
version: "1.4.0"
92+
checked_yaml:
93+
dependency: transitive
94+
description:
95+
name: checked_yaml
96+
sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f"
97+
url: "https://pub.dev"
98+
source: hosted
99+
version: "2.0.4"
92100
cli_config:
93101
dependency: transitive
94102
description:
@@ -97,6 +105,14 @@ packages:
97105
url: "https://pub.dev"
98106
source: hosted
99107
version: "0.2.0"
108+
cli_util:
109+
dependency: transitive
110+
description:
111+
name: cli_util
112+
sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
113+
url: "https://pub.dev"
114+
source: hosted
115+
version: "0.4.2"
100116
clock:
101117
dependency: transitive
102118
description:
@@ -270,6 +286,14 @@ packages:
270286
url: "https://pub.dev"
271287
source: hosted
272288
version: "9.1.1"
289+
flutter_launcher_icons:
290+
dependency: "direct main"
291+
description:
292+
name: flutter_launcher_icons
293+
sha256: "10f13781741a2e3972126fae08393d3c4e01fa4cd7473326b94b72cf594195e7"
294+
url: "https://pub.dev"
295+
source: hosted
296+
version: "0.14.4"
273297
flutter_localizations:
274298
dependency: "direct main"
275299
description: flutter
@@ -356,7 +380,7 @@ packages:
356380
description:
357381
path: "."
358382
ref: HEAD
359-
resolved-ref: "028ebfa29ebc8f95c2da30fee68566723d1e6897"
383+
resolved-ref: "3a8dc5ff81c59805fa59996517eb0fdf136a0b67"
360384
url: "https://github.com/headlines-toolkit/ht-auth-inmemory"
361385
source: git
362386
version: "0.0.0"
@@ -501,10 +525,18 @@ packages:
501525
dependency: transitive
502526
description:
503527
name: js
504-
sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc"
528+
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
529+
url: "https://pub.dev"
530+
source: hosted
531+
version: "0.6.7"
532+
js_interop:
533+
dependency: "direct main"
534+
description:
535+
name: js_interop
536+
sha256: "7ec859c296958ccea34dc770504bd3ff4ae52fdd9e7eeb2bacc7081ad476a1f5"
505537
url: "https://pub.dev"
506538
source: hosted
507-
version: "0.7.2"
539+
version: "0.0.1"
508540
json_annotation:
509541
dependency: transitive
510542
description:

0 commit comments

Comments
 (0)