TF-886 Clear AuthenticationInfo
This commit is contained in:
@@ -11,6 +11,7 @@ class AuthenticationInfoCacheClient extends HiveCacheClient<AuthenticationInfoCa
|
||||
@override
|
||||
Future<void> clearAllData() {
|
||||
return Future.sync(() async {
|
||||
await HiveCacheConfig.removeEncryptionKey();
|
||||
final boxAuthenticationInfo = await openBox();
|
||||
return boxAuthenticationInfo.clear();
|
||||
}).catchError((error) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:tmail_ui_user/features/caching/account_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/authentication_info_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/email_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/mailbox_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/recent_search_cache_client.dart';
|
||||
@@ -15,6 +16,7 @@ class CachingManager {
|
||||
final RecentSearchCacheClient _recentSearchCacheClient;
|
||||
final TokenOidcCacheClient _tokenOidcCacheClient;
|
||||
final AccountCacheClient _accountCacheClient;
|
||||
final AuthenticationInfoCacheClient _authenticationInfoCacheClient;
|
||||
|
||||
CachingManager(
|
||||
this._mailboxCacheClient,
|
||||
@@ -22,7 +24,8 @@ class CachingManager {
|
||||
this._emailCacheClient,
|
||||
this._recentSearchCacheClient,
|
||||
this._tokenOidcCacheClient,
|
||||
this._accountCacheClient
|
||||
this._accountCacheClient,
|
||||
this._authenticationInfoCacheClient,
|
||||
);
|
||||
|
||||
Future<void> clearAll() async {
|
||||
@@ -33,7 +36,8 @@ class CachingManager {
|
||||
_emailCacheClient.clearAllData(),
|
||||
_recentSearchCacheClient.clearAllData(),
|
||||
_tokenOidcCacheClient.clearAllData(),
|
||||
_accountCacheClient.clearAllData()
|
||||
_accountCacheClient.clearAllData(),
|
||||
_authenticationInfoCacheClient.clearAllData(),
|
||||
]);
|
||||
} else {
|
||||
await Future.wait([
|
||||
@@ -42,7 +46,8 @@ class CachingManager {
|
||||
_emailCacheClient.deleteBox(),
|
||||
_recentSearchCacheClient.deleteBox(),
|
||||
_tokenOidcCacheClient.deleteBox(),
|
||||
_accountCacheClient.deleteBox()
|
||||
_accountCacheClient.deleteBox(),
|
||||
_authenticationInfoCacheClient.deleteBox(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,11 @@ class HiveCacheConfig {
|
||||
return encryptionKey;
|
||||
}
|
||||
|
||||
static Future<bool> removeEncryptionKey() {
|
||||
final sharedPreference = Get.find<SharedPreferences>();
|
||||
return sharedPreference.remove(LoginConstant.keyHiveEncrypt);
|
||||
}
|
||||
|
||||
void registerAdapter() {
|
||||
Hive.registerAdapter(MailboxCacheAdapter());
|
||||
Hive.registerAdapter(MailboxRightsCacheAdapter());
|
||||
|
||||
@@ -15,4 +15,8 @@ class AuthenticationInfoCacheManager {
|
||||
Future<AuthenticationInfoCache?> getAuthenticationInfoStored() {
|
||||
return _authenticationInfoCacheClient.getItem(AuthenticationInfoCache.keyCacheValue);
|
||||
}
|
||||
|
||||
Future<void> removeAuthenticationInfo() {
|
||||
return _authenticationInfoCacheClient.deleteItem(AuthenticationInfoCache.keyCacheValue);
|
||||
}
|
||||
}
|
||||
@@ -32,16 +32,6 @@ class CredentialRepositoryImpl extends CredentialRepository {
|
||||
await sharedPreferences.remove(LoginConstant.keyBaseUrl);
|
||||
}
|
||||
|
||||
@override
|
||||
Future removePassword() async {
|
||||
await sharedPreferences.remove(LoginConstant.keyPassword);
|
||||
}
|
||||
|
||||
@override
|
||||
Future removeUserName() async {
|
||||
await sharedPreferences.remove(LoginConstant.keyUserName);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<UserProfile> getUserProfile() async {
|
||||
final json = sharedPreferences.getString(LoginConstant.keyUserProfile) ?? '';
|
||||
@@ -70,4 +60,9 @@ class CredentialRepositoryImpl extends CredentialRepository {
|
||||
Future<AuthenticationInfoCache?> getAuthenticationInfoStored() {
|
||||
return _authenticationInfoCacheManager.getAuthenticationInfoStored();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> removeAuthenticationInfo() {
|
||||
return _authenticationInfoCacheManager.removeAuthenticationInfo();
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,6 @@ abstract class CredentialRepository {
|
||||
|
||||
Future<Uri> getBaseUrl();
|
||||
|
||||
Future removeUserName();
|
||||
|
||||
Future removePassword();
|
||||
|
||||
Future saveUserProfile(UserProfile userProfile);
|
||||
|
||||
Future removeUserProfile();
|
||||
@@ -21,4 +17,6 @@ abstract class CredentialRepository {
|
||||
Future<void> storeAuthenticationInfo(AuthenticationInfoCache authenticationInfoCache);
|
||||
|
||||
Future<AuthenticationInfoCache?> getAuthenticationInfoStored();
|
||||
|
||||
Future<void> removeAuthenticationInfo();
|
||||
}
|
||||
@@ -14,8 +14,7 @@ class DeleteCredentialInteractor {
|
||||
try {
|
||||
await Future.wait([
|
||||
credentialRepository.removeBaseUrl(),
|
||||
credentialRepository.removeUserName(),
|
||||
credentialRepository.removePassword(),
|
||||
credentialRepository.removeAuthenticationInfo(),
|
||||
credentialRepository.removeUserProfile(),
|
||||
]);
|
||||
return Right(DeleteCredentialSuccess());
|
||||
|
||||
Reference in New Issue
Block a user