π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix(auth): prevent app lock data from being cleared on restart in offline mode
Prateek Sunal442010cb0b8c
diff --git a/mobile/apps/auth/lib/main.dart b/mobile/apps/auth/lib/main.dartindex 2e10a1ef5b..9cb3905dd4 100644--- a/mobile/apps/auth/lib/main.dart+++ b/mobile/apps/auth/lib/main.dart@@ -176,5 +176,8 @@ Future<void> _init(bool bool, {String? via}) async {await NotificationService.instance.init();await UpdateService.instance.init();await IconUtils.instance.init();- await LockScreenSettings.instance.init(Configuration.instance);+ await LockScreenSettings.instance.init(+ Configuration.instance,+ hasOptedForOfflineMode: Configuration.instance.hasOptedForOfflineMode(),+ );}diff --git a/mobile/packages/lock_screen/lib/lock_screen_settings.dart b/mobile/packages/lock_screen/lib/lock_screen_settings.dartindex 35499225f5..3019849d25 100644--- a/mobile/packages/lock_screen/lib/lock_screen_settings.dart+++ b/mobile/packages/lock_screen/lib/lock_screen_settings.dart@@ -45,7 +45,10 @@ class LockScreenSettings {late SharedPreferences _preferences;late FlutterSecureStorage _secureStorage;- Future<void> init(BaseConfiguration config) async {+ Future<void> init(+ BaseConfiguration config, {+ bool hasOptedForOfflineMode = false,+ }) async {_config = config;_secureStorage = const FlutterSecureStorage();_preferences = await SharedPreferences.getInstance();@@ -57,7 +60,7 @@ class LockScreenSettings {/// already been done by checking a stored boolean value.await runLockScreenChangesMigration();- await _clearLsDataInKeychainIfFreshInstall();+ await _clearLsDataInKeychainIfFreshInstall(hasOptedForOfflineMode);Bus.instance.on<SignedOutEvent>().listen((event) {removePinAndPassword();@@ -240,8 +243,12 @@ class LockScreenSettings {// If the app was uninstalled (without logging out if it was used with// backups), keychain items of the app persist in the keychain. To avoid using// old keychain items, we delete them on reinstall.- Future<void> _clearLsDataInKeychainIfFreshInstall() async {- if ((Platform.isIOS || Platform.isMacOS) && !_config.isLoggedIn()) {+ Future<void> _clearLsDataInKeychainIfFreshInstall(+ bool hasOptedForOfflineMode,+ ) async {+ if ((Platform.isIOS || Platform.isMacOS) &&+ !_config.isLoggedIn() &&+ !hasOptedForOfflineMode) {await _secureStorage.delete(key: password);await _secureStorage.delete(key: pin);await _secureStorage.delete(key: saltKey);