This commit is contained in:
Felipe
2024-02-19 18:16:51 -05:00
parent 9e6f76e309
commit 997c6047bb
34 changed files with 1235 additions and 594 deletions
@@ -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