Save the encryption preference to configuration
This commit is contained in:
parent
c7b40265c3
commit
b4940d4fdd
2 changed files with 11 additions and 0 deletions
|
@ -10,6 +10,7 @@ class Configuration {
|
|||
static const usernameKey = "username";
|
||||
static const userIDKey = "user_id";
|
||||
static const passwordKey = "password";
|
||||
static const hasOptedForE2EKey = "has_opted_for_e2e_encryption";
|
||||
static const keyKey = "key";
|
||||
|
||||
SharedPreferences _preferences;
|
||||
|
@ -65,6 +66,14 @@ class Configuration {
|
|||
await _preferences.setString(passwordKey, password);
|
||||
}
|
||||
|
||||
void setOptInForE2E(bool hasOptedForE2E) async {
|
||||
await _preferences.setBool(hasOptedForE2EKey, hasOptedForE2E);
|
||||
}
|
||||
|
||||
bool hasOptedForE2E() {
|
||||
return _preferences.getBool(hasOptedForE2EKey);
|
||||
}
|
||||
|
||||
void generateAndSaveKey(String passphrase) async {
|
||||
final key = CryptoUtil.createCryptoRandomString();
|
||||
await _preferences.setString(keyKey, CryptoUtil.encrypt(key, passphrase));
|
||||
|
|
|
@ -275,6 +275,7 @@ class SelectEncryptionLevelWidget extends StatelessWidget {
|
|||
child: Text('Use E2E encryption'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Configuration.instance.setOptInForE2E(true);
|
||||
_showEnterPassphraseDialog(context);
|
||||
},
|
||||
),
|
||||
|
@ -282,6 +283,7 @@ class SelectEncryptionLevelWidget extends StatelessWidget {
|
|||
child: Text("Use encryption at rest"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Configuration.instance.setOptInForE2E(false);
|
||||
Bus.instance.fire(UserAuthenticatedEvent());
|
||||
},
|
||||
),
|
||||
|
|
Loading…
Add table
Reference in a new issue