before
This commit is contained in:
@@ -19,13 +19,23 @@ class AuthenticationBloc
|
||||
_userSubscription = userRepository.streamUser().listen((authUser) {
|
||||
add(AuthenticationUserChanged(authUser));
|
||||
});
|
||||
on<AuthenticationUserChanged>((event, emit) {
|
||||
if (event.user != null) {
|
||||
emit(AuthenticationState.authenticated(event.user!));
|
||||
} else {
|
||||
emit(const AuthenticationState.unauthenticated());
|
||||
}
|
||||
});
|
||||
on<AuthenticationUserChanged>(_onAuthenticationUserChanged);
|
||||
on<AuthenticationLogoutRequested>(_onAuthenticationLogoutRequested);
|
||||
}
|
||||
|
||||
void _onAuthenticationUserChanged(
|
||||
AuthenticationUserChanged event, Emitter<AuthenticationState> emit) {
|
||||
emit(
|
||||
event.user != null
|
||||
? AuthenticationState.authenticated(event.user!)
|
||||
: const AuthenticationState.unauthenticated(),
|
||||
);
|
||||
}
|
||||
|
||||
void _onAuthenticationLogoutRequested(AuthenticationLogoutRequested event,
|
||||
Emitter<AuthenticationState> emit) async {
|
||||
await userRepository.logOut();
|
||||
emit(const AuthenticationState.unauthenticated());
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user