Skip to content

Commit

Permalink
fix: Fixed crypto store not being saved on local storage under certai…
Browse files Browse the repository at this point in the history
…n circumstances.
  • Loading branch information
Skyost committed Feb 9, 2025
1 parent 941c7ba commit eac2a1f
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/model/crypto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,21 @@ class StoredCryptoStore extends AsyncNotifier<CryptoStore?> {
throw Exception('Password mismatch.');
}
}
Future<void> saveCryptoStoreOnLocalStorage() async => await SimpleSecureStorage.write(_kPasswordDerivedKeyKey, base64.encode(await newCryptoStore!.key.exportRawKey()));
await salt.saveToLocalStorage();
if (checkSettings) {
await salt.saveToLocalStorage();
AppUnlockMethod unlockMethod = await ref.read(appUnlockMethodSettingsEntryProvider.future);
if (unlockMethod is MasterPasswordAppUnlockMethod) {
await ref.read(passwordSignatureVerificationMethodProvider.notifier).enable(newPassword);
} else {
await saveCryptoStoreOnLocalStorage();
}
} else {
_saveOnLocalStorage(newCryptoStore);
await saveCryptoStoreOnLocalStorage();
}
use(newCryptoStore);
return newCryptoStore;
}

/// Saves the [cryptoStore] on disk.
Future<CryptoStore> _saveOnLocalStorage(CryptoStore cryptoStore) async {
await cryptoStore.salt.saveToLocalStorage();
await SimpleSecureStorage.write(_kPasswordDerivedKeyKey, base64.encode(await cryptoStore.key.exportRawKey()));
return cryptoStore;
}
}

/// Allows to encrypt some data according to a key.
Expand Down

0 comments on commit eac2a1f

Please sign in to comment.