mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-10-31 17:37:41 +00:00
4120394121
* chore: Setup * feat: Verbose controls for TOTP 2FA WIP [skip-ci] * feat: Implement verbose controls for sends to contact, non contacts and internal wallets * feat: Implement verbose 2FA control for exchanges to internal wallets [skip-ci] * Implement verbose controls * chore: PR cleanup * fix: Implement fixes and recommendations on verbose controls * feat: Localization for verbose controls settings * fix: disable pin when 2fa is not activated * fix: Naming error * chore: Reformat code with linelength of 100 * fix: Wallet type page and type bug when creating wallet * fix: add new values to be stored in local storage to both reload function and import/export functions in back_service.dart * fix: White spaces with localization files * fix: Switch observers in modify_2fa page to individual observer * chore: Switch custom tab widget to reusable SettingsChoicesCell widget * chore: Remove unneeded argument in create wallet entrypoint * fix: Switch type for selectedCakePreference when importing preferences from backup file * fix: Await all values being saved to local storage --------- Co-authored-by: David Adegoke <blazebrain@Davids-MacBook-Pro.local>
48 lines
1.6 KiB
Dart
48 lines
1.6 KiB
Dart
import 'package:cake_wallet/core/auth_service.dart';
|
|
import 'package:cake_wallet/entities/biometric_auth.dart';
|
|
import 'package:cake_wallet/entities/pin_code_required_duration.dart';
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
part 'security_settings_view_model.g.dart';
|
|
|
|
class SecuritySettingsViewModel = SecuritySettingsViewModelBase with _$SecuritySettingsViewModel;
|
|
|
|
abstract class SecuritySettingsViewModelBase with Store {
|
|
SecuritySettingsViewModelBase(
|
|
this._settingsStore,
|
|
this._authService,
|
|
) : _biometricAuth = BiometricAuth();
|
|
|
|
final BiometricAuth _biometricAuth;
|
|
final SettingsStore _settingsStore;
|
|
final AuthService _authService;
|
|
|
|
@computed
|
|
bool get allowBiometricalAuthentication => _settingsStore.allowBiometricalAuthentication;
|
|
|
|
@computed
|
|
bool get useTotp2FA => _settingsStore.useTOTP2FA;
|
|
|
|
@computed
|
|
bool get shouldRequireTOTP2FAForAllSecurityAndBackupSettings =>
|
|
_settingsStore.shouldRequireTOTP2FAForAllSecurityAndBackupSettings;
|
|
|
|
@computed
|
|
PinCodeRequiredDuration get pinCodeRequiredDuration => _settingsStore.pinTimeOutDuration;
|
|
|
|
@action
|
|
Future<bool> biometricAuthenticated() async {
|
|
return await _biometricAuth.canCheckBiometrics() && await _biometricAuth.isAuthenticated();
|
|
}
|
|
|
|
@action
|
|
void setAllowBiometricalAuthentication(bool value) =>
|
|
_settingsStore.allowBiometricalAuthentication = value;
|
|
|
|
@action
|
|
setPinCodeRequiredDuration(PinCodeRequiredDuration duration) =>
|
|
_settingsStore.pinTimeOutDuration = duration;
|
|
|
|
bool checkPinCodeRiquired() => _authService.requireAuth();
|
|
}
|