diff --git a/src/Android/MainApplication.cs b/src/Android/MainApplication.cs index de40bdd9b..cc2361821 100644 --- a/src/Android/MainApplication.cs +++ b/src/Android/MainApplication.cs @@ -68,7 +68,6 @@ namespace Bit.Droid ServiceContainer.Register("deleteAccountActionFlowExecutioner", deleteAccountActionFlowExecutioner); var verificationActionsFlowHelper = new VerificationActionsFlowHelper( - ServiceContainer.Resolve("keyConnectorService"), ServiceContainer.Resolve("passwordRepromptService"), ServiceContainer.Resolve("cryptoService"), ServiceContainer.Resolve()); diff --git a/src/App/Pages/Settings/ExportVaultPageViewModel.cs b/src/App/Pages/Settings/ExportVaultPageViewModel.cs index dc2452abc..8bcfcd357 100644 --- a/src/App/Pages/Settings/ExportVaultPageViewModel.cs +++ b/src/App/Pages/Settings/ExportVaultPageViewModel.cs @@ -65,7 +65,7 @@ namespace Bit.App.Pages _initialized = true; FileFormatSelectedIndex = FileFormatOptions.FindIndex(k => k.Key == "json"); DisablePrivateVaultPolicyEnabled = await _policyService.PolicyAppliesToUser(PolicyType.DisablePersonalVaultExport); - UseOTPVerification = !await _userVerificationService.HasMasterPasswordAsync(); + UseOTPVerification = !await _userVerificationService.HasMasterPasswordAsync(true); if (UseOTPVerification) { @@ -163,7 +163,7 @@ namespace Bit.App.Pages return; } - var verificationType = await _userVerificationService.HasMasterPasswordAsync() + var verificationType = await _userVerificationService.HasMasterPasswordAsync(true) ? VerificationType.MasterPassword : VerificationType.OTP; if (!await _userVerificationService.VerifyUser(Secret, verificationType)) diff --git a/src/App/Utilities/VerificationActionsFlowHelper.cs b/src/App/Utilities/VerificationActionsFlowHelper.cs index 9c024298d..8d916f051 100644 --- a/src/App/Utilities/VerificationActionsFlowHelper.cs +++ b/src/App/Utilities/VerificationActionsFlowHelper.cs @@ -60,7 +60,6 @@ namespace Bit.App.Utilities /// public class VerificationActionsFlowHelper : IVerificationActionsFlowHelper { - private readonly IKeyConnectorService _keyConnectorService; private readonly IPasswordRepromptService _passwordRepromptService; private readonly ICryptoService _cryptoService; private readonly IUserVerificationService _userVerificationService; @@ -72,12 +71,11 @@ namespace Bit.App.Utilities private readonly Dictionary _actionExecutionerDictionary = new Dictionary(); - public VerificationActionsFlowHelper(IKeyConnectorService keyConnectorService, + public VerificationActionsFlowHelper( IPasswordRepromptService passwordRepromptService, ICryptoService cryptoService, IUserVerificationService userVerificationService) { - _keyConnectorService = keyConnectorService; _passwordRepromptService = passwordRepromptService; _cryptoService = cryptoService; _userVerificationService = userVerificationService; @@ -110,7 +108,7 @@ namespace Bit.App.Utilities public async Task ValidateAndExecuteAsync() { - var verificationType = await _userVerificationService.HasMasterPasswordAsync() + var verificationType = await _userVerificationService.HasMasterPasswordAsync(true) ? VerificationType.MasterPassword : VerificationType.OTP; diff --git a/src/Core/Abstractions/IUserVerificationService.cs b/src/Core/Abstractions/IUserVerificationService.cs index cf8e61b6c..8a20595ed 100644 --- a/src/Core/Abstractions/IUserVerificationService.cs +++ b/src/Core/Abstractions/IUserVerificationService.cs @@ -6,6 +6,6 @@ namespace Bit.Core.Abstractions public interface IUserVerificationService { Task VerifyUser(string secret, VerificationType verificationType); - Task HasMasterPasswordAsync(); + Task HasMasterPasswordAsync(bool checkMasterKeyHash = false); } } diff --git a/src/Core/Services/UserVerificationService.cs b/src/Core/Services/UserVerificationService.cs index d7c696bf8..3bd0c1f20 100644 --- a/src/Core/Services/UserVerificationService.cs +++ b/src/Core/Services/UserVerificationService.cs @@ -68,15 +68,20 @@ namespace Bit.Core.Services await _platformUtilsService.ShowDialogAsync(errorMessage); } - public async Task HasMasterPasswordAsync() + public async Task HasMasterPasswordAsync(bool checkMasterKeyHash = false) { + async Task CheckMasterKeyHashAsync() + { + return !checkMasterKeyHash && await _cryptoService.GetMasterKeyHashAsync() != null; + }; + var decryptOptions = await _stateService.GetAccountDecryptionOptions(); if (decryptOptions != null) { - return decryptOptions.HasMasterPassword; + return decryptOptions.HasMasterPassword && await CheckMasterKeyHashAsync(); } - return !await _keyConnectorService.GetUsesKeyConnectorAsync(); + return !await _keyConnectorService.GetUsesKeyConnectorAsync() && await CheckMasterKeyHashAsync(); } } } diff --git a/src/iOS.Core/Utilities/iOSCoreHelpers.cs b/src/iOS.Core/Utilities/iOSCoreHelpers.cs index 14588cd59..1c713147d 100644 --- a/src/iOS.Core/Utilities/iOSCoreHelpers.cs +++ b/src/iOS.Core/Utilities/iOSCoreHelpers.cs @@ -245,7 +245,6 @@ namespace Bit.iOS.Core.Utilities ServiceContainer.Register("deleteAccountActionFlowExecutioner", deleteAccountActionFlowExecutioner); var verificationActionsFlowHelper = new VerificationActionsFlowHelper( - ServiceContainer.Resolve("keyConnectorService"), ServiceContainer.Resolve("passwordRepromptService"), ServiceContainer.Resolve("cryptoService"), ServiceContainer.Resolve());