mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-28 11:34:52 +01:00
fix: Cake-2FA-setup-issue (#1097)
* fix: Cake 2FA setup issue * fix: 2FA Setup issue * fix: 2FA setup bug
This commit is contained in:
@@ -27,7 +27,6 @@ abstract class Setup2FAViewModelBase with Store {
|
||||
unhighlightTabs = false,
|
||||
selected2FASettings = ObservableList<VerboseControlSettings>(),
|
||||
state = InitialExecutionState() {
|
||||
_getRandomBase32SecretKey();
|
||||
selectCakePreset(selectedCake2FAPreset);
|
||||
reaction((_) => state, _saveLastAuthTime);
|
||||
}
|
||||
@@ -36,9 +35,12 @@ abstract class Setup2FAViewModelBase with Store {
|
||||
static const banTimeout = 180; // 3 minutes
|
||||
final banTimeoutKey = S.current.auth_store_ban_timeout;
|
||||
|
||||
String get secretKey => _settingsStore.totpSecretKey;
|
||||
String get deviceName => _settingsStore.deviceName;
|
||||
String get totpVersionOneLink => _settingsStore.totpVersionOneLink;
|
||||
|
||||
@computed
|
||||
String get totpSecretKey => _settingsStore.totpSecretKey;
|
||||
|
||||
String totpVersionOneLink = '';
|
||||
|
||||
@observable
|
||||
ExecutionState state;
|
||||
@@ -84,9 +86,14 @@ abstract class Setup2FAViewModelBase with Store {
|
||||
bool get shouldRequireTOTP2FAForAllSecurityAndBackupSettings =>
|
||||
_settingsStore.shouldRequireTOTP2FAForAllSecurityAndBackupSettings;
|
||||
|
||||
void _getRandomBase32SecretKey() {
|
||||
final randomBase32Key = Utils.generateRandomBase32SecretKey(16);
|
||||
_setBase32SecretKey(randomBase32Key);
|
||||
@action
|
||||
void generateSecretKey() {
|
||||
final _totpSecretKey = Utils.generateRandomBase32SecretKey(16);
|
||||
|
||||
totpVersionOneLink =
|
||||
'otpauth://totp/Cake%20Wallet:$deviceName?secret=$_totpSecretKey&issuer=Cake%20Wallet&algorithm=SHA512&digits=8&period=30';
|
||||
|
||||
setTOTPSecretKey(_totpSecretKey);
|
||||
}
|
||||
|
||||
@action
|
||||
@@ -95,15 +102,10 @@ abstract class Setup2FAViewModelBase with Store {
|
||||
}
|
||||
|
||||
@action
|
||||
void _setBase32SecretKey(String value) {
|
||||
void setTOTPSecretKey(String value) {
|
||||
_settingsStore.totpSecretKey = value;
|
||||
}
|
||||
|
||||
@action
|
||||
void clearBase32SecretKey() {
|
||||
_settingsStore.totpSecretKey = '';
|
||||
}
|
||||
|
||||
Duration? banDuration() {
|
||||
final unbanTimestamp = _sharedPreferences.getInt(banTimeoutKey);
|
||||
|
||||
@@ -145,7 +147,7 @@ abstract class Setup2FAViewModelBase with Store {
|
||||
}
|
||||
|
||||
final result = Utils.verify(
|
||||
secretKey: secretKey,
|
||||
secretKey: totpSecretKey,
|
||||
otp: otpText,
|
||||
);
|
||||
|
||||
@@ -156,7 +158,6 @@ abstract class Setup2FAViewModelBase with Store {
|
||||
} else {
|
||||
final value = _settingsStore.numberOfFailedTokenTrials + 1;
|
||||
adjustTokenTrialNumber(value);
|
||||
print(value);
|
||||
if (_failureCounter >= maxFailedTrials) {
|
||||
final banDuration = await ban();
|
||||
state = AuthenticationBanned(
|
||||
|
||||
Reference in New Issue
Block a user