mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
* bio auth mac fix * remove comment and change duration from 2 to 0 * cherry pick previous changes * workaround for secure storage bug on mac * bump version to 3.19.5 (because breez will need this version anyways) * some code cleanup * some changess didn't get saved * just documenting the issue [skip ci] * undo accidental removal + minor code cleanup * merge conflicts * Minor UI change [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
45 lines
1.4 KiB
Dart
45 lines
1.4 KiB
Dart
import 'package:cake_wallet/core/secure_storage.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
import 'package:cake_wallet/entities/secret_store_key.dart';
|
|
import 'package:cake_wallet/store/secret_store.dart';
|
|
|
|
part 'edit_backup_password_view_model.g.dart';
|
|
|
|
class EditBackupPasswordViewModel = EditBackupPasswordViewModelBase
|
|
with _$EditBackupPasswordViewModel;
|
|
|
|
abstract class EditBackupPasswordViewModelBase with Store {
|
|
EditBackupPasswordViewModelBase(this.secureStorage, this.secretStore)
|
|
: backupPassword = secretStore.read(generateStoreKeyFor(key: SecretStoreKey.backupPassword)),
|
|
_originalPassword = '';
|
|
|
|
final FlutterSecureStorage secureStorage;
|
|
final SecretStore secretStore;
|
|
|
|
@observable
|
|
String backupPassword;
|
|
|
|
@computed
|
|
bool get canSave {
|
|
return !(_originalPassword == backupPassword);
|
|
}
|
|
|
|
String _originalPassword;
|
|
|
|
@action
|
|
Future<void> init() async {
|
|
final key = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
|
final password = (await secureStorage.read(key: key))!;
|
|
_originalPassword = password;
|
|
backupPassword = password;
|
|
}
|
|
|
|
@action
|
|
Future<void> save() async {
|
|
final key = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
|
await writeSecureStorage(secureStorage, key: key, value: backupPassword);
|
|
secretStore.write(key: key, value: backupPassword);
|
|
}
|
|
}
|