TF-1842: Create SendingEmailBinding and implement in SendingEmailObserver

(cherry picked from commit 7ec20283d7d119857ab7e689139e226c15a2137c)
This commit is contained in:
HuyNguyen
2023-05-31 00:56:35 +07:00
committed by Dat Vu
parent d626fc6b4c
commit 36ab1316e2
7 changed files with 309 additions and 12 deletions
@@ -12,8 +12,8 @@ class AuthenticationInfoCacheManager {
authenticationInfoCache);
}
Future<AuthenticationInfoCache?> getAuthenticationInfoStored() {
return _authenticationInfoCacheClient.getItem(AuthenticationInfoCache.keyCacheValue);
Future<AuthenticationInfoCache?> getAuthenticationInfoStored({bool needToReopen = false}) {
return _authenticationInfoCacheClient.getItem(AuthenticationInfoCache.keyCacheValue, needToReopen: needToReopen);
}
Future<void> removeAuthenticationInfo() {
@@ -36,8 +36,8 @@ class CredentialRepositoryImpl extends CredentialRepository {
}
@override
Future<AuthenticationInfoCache?> getAuthenticationInfoStored() {
return _authenticationInfoCacheManager.getAuthenticationInfoStored();
Future<AuthenticationInfoCache?> getAuthenticationInfoStored({bool needToReopen = false}) {
return _authenticationInfoCacheManager.getAuthenticationInfoStored(needToReopen: needToReopen);
}
@override
@@ -9,7 +9,7 @@ abstract class CredentialRepository {
Future<void> storeAuthenticationInfo(AuthenticationInfoCache authenticationInfoCache);
Future<AuthenticationInfoCache?> getAuthenticationInfoStored();
Future<AuthenticationInfoCache?> getAuthenticationInfoStored({bool needToReopen = false});
Future<void> removeAuthenticationInfo();
}
@@ -20,7 +20,7 @@ class GetAuthenticatedAccountInteractor {
this._getStoredTokenOidcInteractor
);
Stream<Either<Failure, Success>> execute() async* {
Stream<Either<Failure, Success>> execute({bool needToReopen = false}) async* {
try {
yield Right<Failure, Success>(LoadingState());
final account = await _accountRepository.getCurrentAccount();
@@ -29,7 +29,7 @@ class GetAuthenticatedAccountInteractor {
if (account.authenticationType == AuthenticationType.oidc) {
yield* _getStoredTokenOidcInteractor.execute(account.id);
} else {
yield await _getCredentialInteractor.execute();
yield await _getCredentialInteractor.execute(needToReopen: needToReopen);
}
} catch (e) {
logError('GetAuthenticatedAccountInteractor::execute(): $e');
@@ -15,10 +15,10 @@ class GetCredentialInteractor {
GetCredentialInteractor(this.credentialRepository);
Future<Either<Failure, Success>> execute() async {
Future<Either<Failure, Success>> execute({bool needToReopen = false}) async {
try {
final baseUrl = await credentialRepository.getBaseUrl();
final authenticationInfo = await credentialRepository.getAuthenticationInfoStored();
final authenticationInfo = await credentialRepository.getAuthenticationInfoStored(needToReopen: needToReopen);
if (isCredentialValid(baseUrl) && authenticationInfo != null) {
return Right(GetCredentialViewState(
baseUrl,