π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Code refractoring
AmanRajSinghMourya37928cd2c6e3
diff --git a/mobile/packages/configuration/lib/base_configuration.dart b/mobile/packages/configuration/lib/base_configuration.dartindex 24224de339..d934faea08 100644--- a/mobile/packages/configuration/lib/base_configuration.dart+++ b/mobile/packages/configuration/lib/base_configuration.dart@@ -55,7 +55,7 @@ class BaseConfiguration {// Keys that should not be deleted during logout// These keys are necessary for functionality that needs to work even when users- // aren't signed in, such as using Auth without backup+ // aren't signed in, such as using Auth without backupList<String> preservedKeys = [offlineAuthSecretKey];Future<void> init(List<EnteBaseDatabase> dbs) async {@@ -74,7 +74,17 @@ class BaseConfiguration {Future<void> logout({bool autoLogout = false}) async {await _preferences.clear();+ await resetSecureStorage();+ for (final db in _databases) {+ await db.clearTable();+ }+ _key = null;+ _cachedToken = null;+ _secretKey = null;+ Bus.instance.fire(SignedOutEvent());+ }+ Future<void> resetSecureStorage() async {// Delete all keys except preserved onesfinal allKeys = await _secureStorage.readAll();for (final key in allKeys.keys) {@@ -82,13 +92,6 @@ class BaseConfiguration {await _secureStorage.delete(key: key);}}- for (final db in _databases) {- await db.clearTable();- }- _key = null;- _cachedToken = null;- _secretKey = null;- Bus.instance.fire(SignedOutEvent());}Future<KeyGenResult> generateKey(String password) async {@@ -395,15 +398,7 @@ class BaseConfiguration {Future<void> _setupKeys() async {try {if (!_preferences.containsKey(tokenKey)) {-- // Delete all keys except preserved ones- final allKeys = await _secureStorage.readAll();- for (final key in allKeys.keys) {- if (!preservedKeys.contains(key)) {- await _secureStorage.delete(key: key);- }- }-+ await resetSecureStorage();return;}_key = await _secureStorage.read(key: keyKey);