File tree Expand file tree Collapse file tree 4 files changed +27
-10
lines changed Expand file tree Collapse file tree 4 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -50,10 +50,16 @@ class AppBloc extends Bloc<AppEvent, AppState> {
50
50
AppUserChanged event,
51
51
Emitter <AppState > emit,
52
52
) {
53
- if (event.user.isAnonymous) {
54
- emit (state.copyWith (status: AppStatus .unauthenticated));
55
- } else {
56
- emit (state.copyWith (status: AppStatus .authenticated));
53
+ switch (event.user.authenticationStatus) {
54
+ case AuthenticationStatus .unauthenticated:
55
+ emit (state.copyWith (status: AppStatus .unauthenticated));
56
+ break ;
57
+ case AuthenticationStatus .anonymous:
58
+ emit (state.copyWith (status: AppStatus .anonymous));
59
+ break ;
60
+ case AuthenticationStatus .authenticated:
61
+ emit (state.copyWith (status: AppStatus .authenticated));
62
+ break ;
57
63
}
58
64
}
59
65
Original file line number Diff line number Diff line change 1
1
part of 'app_bloc.dart' ;
2
2
3
- enum AppStatus { authenticated, unauthenticated }
3
+ /// Represents the application's authentication status.
4
+ enum AppStatus {
5
+ /// The user is authenticated.
6
+ authenticated,
7
+
8
+ /// The user is not authenticated.
9
+ unauthenticated,
10
+
11
+ /// The user is anonymous (signed in using an anonymous provider).
12
+ anonymous,
13
+ }
4
14
5
15
class AppState extends Equatable {
6
16
const AppState ({
Original file line number Diff line number Diff line change @@ -15,16 +15,17 @@ final appRouter = GoRouter(
15
15
const authenticationPath = Routes .authentication;
16
16
const headlinesFeedPath = Routes .headlinesFeed;
17
17
18
- // If the user is authenticated, redirect to the headlines feed
18
+ // If the user is authenticated or anonymous , redirect to the headlines feed
19
19
// unless they are already on a route within the headlines feed.
20
- if (appStatus == AppStatus .authenticated) {
20
+ if (appStatus == AppStatus .authenticated ||
21
+ appStatus == AppStatus .anonymous) {
21
22
if (! state.matchedLocation.startsWith (headlinesFeedPath)) {
22
23
return headlinesFeedPath;
23
24
}
24
25
}
25
26
// If the user is not authenticated, redirect to the authentication page
26
27
// unless they are already on a route within the authentication section.
27
- else {
28
+ else if (appStatus == AppStatus .unauthenticated) {
28
29
if (! state.matchedLocation.startsWith (authenticationPath)) {
29
30
return authenticationPath;
30
31
}
Original file line number Diff line number Diff line change @@ -370,7 +370,7 @@ packages:
370
370
description:
371
371
path: "."
372
372
ref: main
373
- resolved-ref: d527953e11fa19f2fadae381488682c574c83831
373
+ resolved-ref: bfad276e63a6d703a635cf743bcf88abcb1d48e0
374
374
url: "https://github.com/headlines-toolkit/ht-authentication-client.git"
375
375
source: git
376
376
version: "0.0.0"
@@ -379,7 +379,7 @@ packages:
379
379
description:
380
380
path: "."
381
381
ref: main
382
- resolved-ref: ca9b62306f54c3e57631cd46c91b1b4426e0a7c3
382
+ resolved-ref: "2c711c1ac23f4f3c866bea9d1152b83c188cf7fa"
383
383
url: "https://github.com/headlines-toolkit/ht-authentication-firebase.git"
384
384
source: git
385
385
version: "0.0.0"
You can’t perform that action at this time.
0 commit comments