mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-26 21:50:27 +00:00
43e062d1ac
* CW-263-TOTP-2FA-in-security-settings WIP * Implement TOTP 2FA WIP * Implement TOTP 2FA Authentication * chore: Remove unneeded formatting * revert formatting * fixes * CW-263-TOTP-2FA-in-security-settings WIP * Setup TOTP Complete, left with Modify TOTF * CW-263-TOTP-2FA-in-security-settings * CW-263-TOTP-2FA-in-security-settings * CW-263-TOTP-2FA-in-security-settings * fix: Add copy-to-clipboard for qr secret key * fix: Translation * chore: Move strings into translation files * feat: End to end flow for TOTP * hotfix: Switch totp to use sha512 * Update strings; 8 digits and error explanation * fix: Totp 2fa implementation feedback * hotfix: same action for button and alert close * feat: App should show both normal and totp auths when totp is enabled * hotfix: prevent barrier from dismissing * fix: Changes requested during PR review * - Minor Enhancements - Minor UI fixes --------- Co-authored-by: Justin Ehrenhofer <justin.ehrenhofer@gmail.com> Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
44 lines
1.4 KiB
Dart
44 lines
1.4 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
|
|
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();
|
|
}
|