Skip to content

Commit eac2a1f

Browse files
committed
fix: Fixed crypto store not being saved on local storage under certain circumstances.
1 parent 941c7ba commit eac2a1f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/model/crypto.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,21 @@ class StoredCryptoStore extends AsyncNotifier<CryptoStore?> {
5858
throw Exception('Password mismatch.');
5959
}
6060
}
61+
Future<void> saveCryptoStoreOnLocalStorage() async => await SimpleSecureStorage.write(_kPasswordDerivedKeyKey, base64.encode(await newCryptoStore!.key.exportRawKey()));
62+
await salt.saveToLocalStorage();
6163
if (checkSettings) {
62-
await salt.saveToLocalStorage();
6364
AppUnlockMethod unlockMethod = await ref.read(appUnlockMethodSettingsEntryProvider.future);
6465
if (unlockMethod is MasterPasswordAppUnlockMethod) {
6566
await ref.read(passwordSignatureVerificationMethodProvider.notifier).enable(newPassword);
67+
} else {
68+
await saveCryptoStoreOnLocalStorage();
6669
}
6770
} else {
68-
_saveOnLocalStorage(newCryptoStore);
71+
await saveCryptoStoreOnLocalStorage();
6972
}
7073
use(newCryptoStore);
7174
return newCryptoStore;
7275
}
73-
74-
/// Saves the [cryptoStore] on disk.
75-
Future<CryptoStore> _saveOnLocalStorage(CryptoStore cryptoStore) async {
76-
await cryptoStore.salt.saveToLocalStorage();
77-
await SimpleSecureStorage.write(_kPasswordDerivedKeyKey, base64.encode(await cryptoStore.key.exportRawKey()));
78-
return cryptoStore;
79-
}
8076
}
8177

8278
/// Allows to encrypt some data according to a key.

0 commit comments

Comments
 (0)