TF-886 Clear AuthenticationInfo

This commit is contained in:
dab246
2022-09-06 19:13:15 +07:00
committed by Dat H. Pham
parent f108f5c726
commit 37d36e90a4
7 changed files with 26 additions and 19 deletions
@@ -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) {
+8 -3
View File
@@ -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());