feat(auth): add reloadCache method in AuthenticationCubit
This commit is contained in:
parent
390fb81b1e
commit
f0ed08bd49
@ -56,6 +56,19 @@ class AuthenticationCubit<Extra> extends Cubit<AuthenticationState<Extra>> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If authenticated, re-emits state with data freshly loaded from cache.
|
||||||
|
FutureOr<void> reloadCache() async {
|
||||||
|
if (state.status == AuthenticationStatus.authenticated) {
|
||||||
|
final data = await _authenticationRepository.getCache();
|
||||||
|
emit(
|
||||||
|
data.fold(
|
||||||
|
AuthenticationState<Extra>.authenticated,
|
||||||
|
(error) => state,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FutureOr<void> signOut() {
|
FutureOr<void> signOut() {
|
||||||
// TODO(hpcl): maybe force unauthenticated by emitting an event
|
// TODO(hpcl): maybe force unauthenticated by emitting an event
|
||||||
_authenticationRepository.signOut();
|
_authenticationRepository.signOut();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user