mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-02 12:14:09 +01:00
[CW-225] Add pin timeout setting
This commit is contained in:
@@ -17,7 +17,9 @@ abstract class AuthViewModelBase with Store {
|
||||
AuthViewModelBase(this._authService, this._sharedPreferences,
|
||||
this._settingsStore, this._biometricAuth)
|
||||
: _failureCounter = 0,
|
||||
state = InitialExecutionState();
|
||||
state = InitialExecutionState(){
|
||||
reaction((_) => state, _saveLastAuthTime);
|
||||
}
|
||||
|
||||
static const maxFailedLogins = 3;
|
||||
static const banTimeout = 180; // 3 minutes
|
||||
@@ -57,7 +59,7 @@ abstract class AuthViewModelBase with Store {
|
||||
|
||||
if (isSuccessfulAuthenticated) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
state = ExecutedSuccessfullyState();
|
||||
state = ExecutedSuccessfullyState();
|
||||
_failureCounter = 0;
|
||||
});
|
||||
} else {
|
||||
@@ -118,4 +120,10 @@ abstract class AuthViewModelBase with Store {
|
||||
state = FailureState(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void _saveLastAuthTime(ExecutionState state){
|
||||
if(state is ExecutedSuccessfullyState){
|
||||
_authService.saveLastAuthTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:cake_wallet/core/auth_service.dart';
|
||||
import 'package:cake_wallet/entities/pin_code_required_duration.dart';
|
||||
import 'package:cake_wallet/store/yat/yat_store.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
@@ -41,6 +43,7 @@ abstract class SettingsViewModelBase with Store {
|
||||
SettingsViewModelBase(
|
||||
this._settingsStore,
|
||||
this._yatStore,
|
||||
this._authService,
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
||||
TransactionInfo>
|
||||
wallet)
|
||||
@@ -94,6 +97,10 @@ abstract class SettingsViewModelBase with Store {
|
||||
@computed
|
||||
FiatCurrency get fiatCurrency => _settingsStore.fiatCurrency;
|
||||
|
||||
@computed
|
||||
PinCodeRequiredDuration get pinCodeRequiredDuration =>
|
||||
_settingsStore.pinTimeOutDuration;
|
||||
|
||||
@computed
|
||||
String get languageCode => _settingsStore.languageCode;
|
||||
|
||||
@@ -135,6 +142,7 @@ abstract class SettingsViewModelBase with Store {
|
||||
final Map<String, String> itemHeaders;
|
||||
final SettingsStore _settingsStore;
|
||||
final YatStore _yatStore;
|
||||
final AuthService _authService;
|
||||
final WalletType walletType;
|
||||
final BiometricAuth _biometricAuth;
|
||||
final WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
||||
@@ -207,19 +215,25 @@ abstract class SettingsViewModelBase with Store {
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
setPinCodeRequiredDuration(PinCodeRequiredDuration duration) =>
|
||||
_settingsStore.pinTimeOutDuration = duration;
|
||||
|
||||
String getDisplayPriority(dynamic priority) {
|
||||
final _priority = priority as TransactionPriority;
|
||||
final _priority = priority as TransactionPriority;
|
||||
|
||||
if (_wallet.type == WalletType.bitcoin
|
||||
|| _wallet.type == WalletType.litecoin) {
|
||||
final rate = bitcoin!.getFeeRate(_wallet, _priority);
|
||||
return bitcoin!.bitcoinTransactionPriorityWithLabel(_priority, rate);
|
||||
}
|
||||
if (_wallet.type == WalletType.bitcoin
|
||||
|| _wallet.type == WalletType.litecoin) {
|
||||
final rate = bitcoin!.getFeeRate(_wallet, _priority);
|
||||
return bitcoin!.bitcoinTransactionPriorityWithLabel(_priority, rate);
|
||||
}
|
||||
|
||||
return priority.toString();
|
||||
return priority.toString();
|
||||
}
|
||||
|
||||
void onDisplayPrioritySelected(TransactionPriority priority) =>
|
||||
_settingsStore.priority[_wallet.type] = priority;
|
||||
_settingsStore.priority[_wallet.type] = priority;
|
||||
|
||||
bool checkPinCodeRiquired() => _authService.requireAuth();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:cake_wallet/core/auth_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_loading_service.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_new_vm.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/di.dart';
|
||||
@@ -55,4 +55,8 @@ abstract class WalletListViewModelBase with Store {
|
||||
info.type == _appStore.wallet!.type,
|
||||
isEnabled: availableWalletTypes.contains(info.type))));
|
||||
}
|
||||
|
||||
bool checkIfAuthRequired(){
|
||||
return getIt.get<AuthService>().requireAuth();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user