diff --git a/src/Android/MainApplication.cs b/src/Android/MainApplication.cs index be1cf8174..33015c4f6 100644 --- a/src/Android/MainApplication.cs +++ b/src/Android/MainApplication.cs @@ -70,7 +70,8 @@ namespace Bit.Droid var verificationActionsFlowHelper = new VerificationActionsFlowHelper( ServiceContainer.Resolve("keyConnectorService"), ServiceContainer.Resolve("passwordRepromptService"), - ServiceContainer.Resolve("cryptoService")); + ServiceContainer.Resolve("cryptoService"), + ServiceContainer.Resolve()); ServiceContainer.Register("verificationActionsFlowHelper", verificationActionsFlowHelper); var accountsManager = new AccountsManager( diff --git a/src/App/Abstractions/IPasswordRepromptService.cs b/src/App/Abstractions/IPasswordRepromptService.cs index 579d9ab44..8684b91da 100644 --- a/src/App/Abstractions/IPasswordRepromptService.cs +++ b/src/App/Abstractions/IPasswordRepromptService.cs @@ -9,7 +9,5 @@ namespace Bit.App.Abstractions Task ShowPasswordPromptAsync(); Task<(string password, bool valid)> ShowPasswordPromptAndGetItAsync(); - - Task Enabled(); } } diff --git a/src/App/Pages/Accounts/LockPage.xaml.cs b/src/App/Pages/Accounts/LockPage.xaml.cs index f19d41f40..316dfbc74 100644 --- a/src/App/Pages/Accounts/LockPage.xaml.cs +++ b/src/App/Pages/Accounts/LockPage.xaml.cs @@ -98,7 +98,7 @@ namespace Bit.App.Pages } else { - if (_vm.UsingKeyConnector && !_vm.PinEnabled) + if (!_vm.HasMasterPassword && !_vm.PinEnabled) { _passwordGrid.IsVisible = false; _unlockButton.IsVisible = false; diff --git a/src/App/Pages/Accounts/LockPageViewModel.cs b/src/App/Pages/Accounts/LockPageViewModel.cs index f283964df..f16c2fafb 100644 --- a/src/App/Pages/Accounts/LockPageViewModel.cs +++ b/src/App/Pages/Accounts/LockPageViewModel.cs @@ -27,7 +27,7 @@ namespace Bit.App.Pages private readonly IEnvironmentService _environmentService; private readonly IStateService _stateService; private readonly IBiometricService _biometricService; - private readonly IKeyConnectorService _keyConnectorService; + private readonly IUserVerificationService _userVerificationService; private readonly ILogger _logger; private readonly IWatchDeviceService _watchDeviceService; private readonly WeakEventManager _secretEntryFocusWeakEventManager = new WeakEventManager(); @@ -44,7 +44,7 @@ namespace Bit.App.Pages private bool _biometricEnabled; private bool _biometricIntegrityValid = true; private bool _biometricButtonVisible; - private bool _usingKeyConnector; + private bool _hasMasterPassword; private string _biometricButtonText; private string _loggedInAsText; private string _lockedVerifyText; @@ -60,7 +60,7 @@ namespace Bit.App.Pages _environmentService = ServiceContainer.Resolve("environmentService"); _stateService = ServiceContainer.Resolve("stateService"); _biometricService = ServiceContainer.Resolve("biometricService"); - _keyConnectorService = ServiceContainer.Resolve("keyConnectorService"); + _userVerificationService = ServiceContainer.Resolve(); _logger = ServiceContainer.Resolve("logger"); _watchDeviceService = ServiceContainer.Resolve(); _policyService = ServiceContainer.Resolve(); @@ -108,9 +108,9 @@ namespace Bit.App.Pages set => SetProperty(ref _pinEnabled, value); } - public bool UsingKeyConnector + public bool HasMasterPassword { - get => _usingKeyConnector; + get => _hasMasterPassword; } public bool BiometricEnabled @@ -182,10 +182,10 @@ namespace Bit.App.Pages BiometricEnabled = await _vaultTimeoutService.IsBiometricLockSetAsync() && await _cryptoService.HasEncryptedUserKeyAsync(); - var decryptOptions = await _stateService.GetAccountDecryptionOptions(); + // Users without MP and without biometric or pin has no MP to unlock with + _hasMasterPassword = await _userVerificationService.HasMasterPasswordAsync(); if (await _stateService.IsAuthenticatedAsync() - && decryptOptions?.TrustedDeviceOption != null - && !decryptOptions.HasMasterPassword + && !_hasMasterPassword && !BiometricEnabled && !PinEnabled) { @@ -193,13 +193,6 @@ namespace Bit.App.Pages return; } - // Users with key connector and without biometric or pin has no MP to unlock with - _usingKeyConnector = await _keyConnectorService.GetUsesKeyConnector(); - if (_usingKeyConnector && !(BiometricEnabled || PinEnabled)) - { - await _vaultTimeoutService.LogOutAsync(); - return; - } _email = await _stateService.GetEmailAsync(); if (string.IsNullOrWhiteSpace(_email)) { @@ -221,16 +214,8 @@ namespace Bit.App.Pages } else { - if (_usingKeyConnector) - { - PageTitle = AppResources.UnlockVault; - LockedVerifyText = AppResources.VaultLockedIdentity; - } - else - { - PageTitle = AppResources.VerifyMasterPassword; - LockedVerifyText = AppResources.VaultLockedMasterPassword; - } + PageTitle = _hasMasterPassword ? AppResources.VerifyMasterPassword : AppResources.UnlockVault; + LockedVerifyText = _hasMasterPassword ? AppResources.VaultLockedMasterPassword : AppResources.VaultLockedIdentity; } if (BiometricEnabled) diff --git a/src/App/Pages/Settings/ExportVaultPageViewModel.cs b/src/App/Pages/Settings/ExportVaultPageViewModel.cs index 403cf6e8c..dc2452abc 100644 --- a/src/App/Pages/Settings/ExportVaultPageViewModel.cs +++ b/src/App/Pages/Settings/ExportVaultPageViewModel.cs @@ -21,7 +21,6 @@ namespace Bit.App.Pages private readonly II18nService _i18nService; private readonly IExportService _exportService; private readonly IPolicyService _policyService; - private readonly IKeyConnectorService _keyConnectorService; private readonly IUserVerificationService _userVerificationService; private readonly IApiService _apiService; private readonly ILogger _logger; @@ -45,8 +44,7 @@ namespace Bit.App.Pages _i18nService = ServiceContainer.Resolve("i18nService"); _exportService = ServiceContainer.Resolve("exportService"); _policyService = ServiceContainer.Resolve("policyService"); - _keyConnectorService = ServiceContainer.Resolve("keyConnectorService"); - _userVerificationService = ServiceContainer.Resolve("userVerificationService"); + _userVerificationService = ServiceContainer.Resolve(); _apiService = ServiceContainer.Resolve("apiService"); _logger = ServiceContainer.Resolve("logger"); @@ -67,7 +65,7 @@ namespace Bit.App.Pages _initialized = true; FileFormatSelectedIndex = FileFormatOptions.FindIndex(k => k.Key == "json"); DisablePrivateVaultPolicyEnabled = await _policyService.PolicyAppliesToUser(PolicyType.DisablePersonalVaultExport); - UseOTPVerification = await _keyConnectorService.GetUsesKeyConnector(); + UseOTPVerification = !await _userVerificationService.HasMasterPasswordAsync(); if (UseOTPVerification) { @@ -165,9 +163,9 @@ namespace Bit.App.Pages return; } - var verificationType = await _keyConnectorService.GetUsesKeyConnector() - ? VerificationType.OTP - : VerificationType.MasterPassword; + var verificationType = await _userVerificationService.HasMasterPasswordAsync() + ? VerificationType.MasterPassword + : VerificationType.OTP; if (!await _userVerificationService.VerifyUser(Secret, verificationType)) { return; diff --git a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs index d47855342..4019c43c0 100644 --- a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs +++ b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs @@ -29,7 +29,7 @@ namespace Bit.App.Pages private readonly IBiometricService _biometricService; private readonly IPolicyService _policyService; private readonly ILocalizeService _localizeService; - private readonly IKeyConnectorService _keyConnectorService; + private readonly IUserVerificationService _userVerificationService; private readonly IClipboardService _clipboardService; private readonly ILogger _loggerService; private readonly IPushNotificationService _pushNotificationService; @@ -89,7 +89,7 @@ namespace Bit.App.Pages _biometricService = ServiceContainer.Resolve("biometricService"); _policyService = ServiceContainer.Resolve("policyService"); _localizeService = ServiceContainer.Resolve("localizeService"); - _keyConnectorService = ServiceContainer.Resolve("keyConnectorService"); + _userVerificationService = ServiceContainer.Resolve(); _clipboardService = ServiceContainer.Resolve("clipboardService"); _loggerService = ServiceContainer.Resolve("logger"); _pushNotificationService = ServiceContainer.Resolve(); @@ -159,8 +159,7 @@ namespace Bit.App.Pages _vaultTimeoutDisplayValue = AppResources.Custom; } - _showChangeMasterPassword = IncludeLinksWithSubscriptionInfo() && - !await _keyConnectorService.GetUsesKeyConnector(); + _showChangeMasterPassword = IncludeLinksWithSubscriptionInfo() && await _userVerificationService.HasMasterPasswordAsync(); _reportLoggingEnabled = await _loggerService.IsEnabled(); _approvePasswordlessLoginRequests = await _stateService.GetApprovePasswordlessLoginsAsync(); _shouldConnectToWatch = await _stateService.GetShouldConnectToWatchAsync(); @@ -443,7 +442,7 @@ namespace Bit.App.Pages if (!string.IsNullOrWhiteSpace(pin)) { var masterPassOnRestart = false; - if (!await _keyConnectorService.GetUsesKeyConnector()) + if (await _userVerificationService.HasMasterPasswordAsync()) { masterPassOnRestart = await _platformUtilsService.ShowDialogAsync( AppResources.PINRequireMasterPasswordRestart, AppResources.UnlockWithPIN, diff --git a/src/App/Pages/Vault/CipherAddEditPage.xaml.cs b/src/App/Pages/Vault/CipherAddEditPage.xaml.cs index 59a246529..6d72804e3 100644 --- a/src/App/Pages/Vault/CipherAddEditPage.xaml.cs +++ b/src/App/Pages/Vault/CipherAddEditPage.xaml.cs @@ -21,7 +21,7 @@ namespace Bit.App.Pages private readonly IDeviceActionService _deviceActionService; private readonly IAutofillHandler _autofillHandler; private readonly IVaultTimeoutService _vaultTimeoutService; - private readonly IKeyConnectorService _keyConnectorService; + private readonly IUserVerificationService _userVerificationService; private CipherAddEditPageViewModel _vm; private bool _fromAutofill; @@ -43,7 +43,7 @@ namespace Bit.App.Pages _deviceActionService = ServiceContainer.Resolve("deviceActionService"); _autofillHandler = ServiceContainer.Resolve(); _vaultTimeoutService = ServiceContainer.Resolve("vaultTimeoutService"); - _keyConnectorService = ServiceContainer.Resolve("keyConnectorService"); + _userVerificationService = ServiceContainer.Resolve(); _appOptions = appOptions; _fromAutofill = fromAutofill; @@ -175,8 +175,8 @@ namespace Bit.App.Pages RequestFocus(_nameEntry); } }); - // Hide password reprompt option if using key connector - _passwordPrompt.IsVisible = !await _keyConnectorService.GetUsesKeyConnector(); + + _passwordPrompt.IsVisible = await _userVerificationService.HasMasterPasswordAsync(); } protected override void OnDisappearing() diff --git a/src/App/Services/MobilePasswordRepromptService.cs b/src/App/Services/MobilePasswordRepromptService.cs index 28a8e5a86..fdec31e82 100644 --- a/src/App/Services/MobilePasswordRepromptService.cs +++ b/src/App/Services/MobilePasswordRepromptService.cs @@ -1,9 +1,7 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using Bit.App.Abstractions; using Bit.App.Resources; using Bit.Core.Abstractions; -using Bit.Core.Utilities; namespace Bit.App.Services { @@ -40,11 +38,5 @@ namespace Bit.App.Services return await _cryptoService.CompareAndUpdateKeyHashAsync(password, null); } - - public async Task Enabled() - { - var keyConnectorService = ServiceContainer.Resolve("keyConnectorService"); - return !await keyConnectorService.GetUsesKeyConnector(); - } } } diff --git a/src/App/Utilities/VerificationActionsFlowHelper.cs b/src/App/Utilities/VerificationActionsFlowHelper.cs index febaf798d..9c024298d 100644 --- a/src/App/Utilities/VerificationActionsFlowHelper.cs +++ b/src/App/Utilities/VerificationActionsFlowHelper.cs @@ -63,6 +63,7 @@ namespace Bit.App.Utilities private readonly IKeyConnectorService _keyConnectorService; private readonly IPasswordRepromptService _passwordRepromptService; private readonly ICryptoService _cryptoService; + private readonly IUserVerificationService _userVerificationService; private VerificationFlowAction? _action; private IActionFlowParmeters _parameters; @@ -73,11 +74,13 @@ namespace Bit.App.Utilities public VerificationActionsFlowHelper(IKeyConnectorService keyConnectorService, IPasswordRepromptService passwordRepromptService, - ICryptoService cryptoService) + ICryptoService cryptoService, + IUserVerificationService userVerificationService) { _keyConnectorService = keyConnectorService; _passwordRepromptService = passwordRepromptService; _cryptoService = cryptoService; + _userVerificationService = userVerificationService; _actionExecutionerDictionary.Add(VerificationFlowAction.DeleteAccount, ServiceContainer.Resolve("deleteAccountActionFlowExecutioner")); } @@ -107,9 +110,9 @@ namespace Bit.App.Utilities public async Task ValidateAndExecuteAsync() { - var verificationType = await _keyConnectorService.GetUsesKeyConnector() - ? VerificationType.OTP - : VerificationType.MasterPassword; + var verificationType = await _userVerificationService.HasMasterPasswordAsync() + ? VerificationType.MasterPassword + : VerificationType.OTP; switch (verificationType) { diff --git a/src/Core/Abstractions/IKeyConnectorService.cs b/src/Core/Abstractions/IKeyConnectorService.cs index be49a5a0e..4de3793bb 100644 --- a/src/Core/Abstractions/IKeyConnectorService.cs +++ b/src/Core/Abstractions/IKeyConnectorService.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using Bit.Core.Models.Domain; using Bit.Core.Models.Response; @@ -8,7 +7,7 @@ namespace Bit.Core.Abstractions public interface IKeyConnectorService { Task SetUsesKeyConnector(bool usesKeyConnector); - Task GetUsesKeyConnector(); + Task GetUsesKeyConnectorAsync(); Task UserNeedsMigration(); Task MigrateUser(); Task GetAndSetKeyAsync(string url); diff --git a/src/Core/Abstractions/IUserVerificationService.cs b/src/Core/Abstractions/IUserVerificationService.cs index 5f47af210..cf8e61b6c 100644 --- a/src/Core/Abstractions/IUserVerificationService.cs +++ b/src/Core/Abstractions/IUserVerificationService.cs @@ -6,5 +6,6 @@ namespace Bit.Core.Abstractions public interface IUserVerificationService { Task VerifyUser(string secret, VerificationType verificationType); + Task HasMasterPasswordAsync(); } } diff --git a/src/Core/Services/KeyConnectorService.cs b/src/Core/Services/KeyConnectorService.cs index d04cf2298..85d1ae1b4 100644 --- a/src/Core/Services/KeyConnectorService.cs +++ b/src/Core/Services/KeyConnectorService.cs @@ -47,7 +47,7 @@ namespace Bit.Core.Services await _stateService.SetUsesKeyConnectorAsync(usesKeyConnector); } - public async Task GetUsesKeyConnector() + public async Task GetUsesKeyConnectorAsync() { return await _stateService.GetUsesKeyConnectorAsync(); } @@ -82,7 +82,7 @@ namespace Bit.Core.Services { var loggedInUsingSso = await _tokenService.GetIsExternal(); var requiredByOrganization = await GetManagingOrganization() != null; - var userIsNotUsingKeyConnector = !await GetUsesKeyConnector(); + var userIsNotUsingKeyConnector = !await GetUsesKeyConnectorAsync(); return loggedInUsingSso && requiredByOrganization && userIsNotUsingKeyConnector; } diff --git a/src/Core/Services/UserVerificationService.cs b/src/Core/Services/UserVerificationService.cs index 74031b55c..d7c696bf8 100644 --- a/src/Core/Services/UserVerificationService.cs +++ b/src/Core/Services/UserVerificationService.cs @@ -11,14 +11,18 @@ namespace Bit.Core.Services private readonly IPlatformUtilsService _platformUtilsService; private readonly II18nService _i18nService; private readonly ICryptoService _cryptoService; + private readonly IStateService _stateService; + private readonly IKeyConnectorService _keyConnectorService; public UserVerificationService(IApiService apiService, IPlatformUtilsService platformUtilsService, - II18nService i18nService, ICryptoService cryptoService) + II18nService i18nService, ICryptoService cryptoService, IStateService stateService, IKeyConnectorService keyConnectorService) { _apiService = apiService; _platformUtilsService = platformUtilsService; _i18nService = i18nService; _cryptoService = cryptoService; + _stateService = stateService; + _keyConnectorService = keyConnectorService; } async public Task VerifyUser(string secret, VerificationType verificationType) @@ -63,5 +67,16 @@ namespace Bit.Core.Services await _platformUtilsService.ShowDialogAsync(errorMessage); } + + public async Task HasMasterPasswordAsync() + { + var decryptOptions = await _stateService.GetAccountDecryptionOptions(); + if (decryptOptions != null) + { + return decryptOptions.HasMasterPassword; + } + + return !await _keyConnectorService.GetUsesKeyConnectorAsync(); + } } } diff --git a/src/Core/Services/VaultTimeoutService.cs b/src/Core/Services/VaultTimeoutService.cs index 28b48c258..0f00cbe53 100644 --- a/src/Core/Services/VaultTimeoutService.cs +++ b/src/Core/Services/VaultTimeoutService.cs @@ -23,7 +23,7 @@ namespace Bit.Core.Services private readonly ISearchService _searchService; private readonly IMessagingService _messagingService; private readonly ITokenService _tokenService; - private readonly IKeyConnectorService _keyConnectorService; + private readonly IUserVerificationService _userVerificationService; private readonly Func, Task> _lockedCallback; private readonly Func, Task> _loggedOutCallback; @@ -37,7 +37,7 @@ namespace Bit.Core.Services ISearchService searchService, IMessagingService messagingService, ITokenService tokenService, - IKeyConnectorService keyConnectorService, + IUserVerificationService userVerificationService, Func, Task> lockedCallback, Func, Task> loggedOutCallback) { @@ -50,7 +50,7 @@ namespace Bit.Core.Services _searchService = searchService; _messagingService = messagingService; _tokenService = tokenService; - _keyConnectorService = keyConnectorService; + _userVerificationService = userVerificationService; _lockedCallback = lockedCallback; _loggedOutCallback = loggedOutCallback; } @@ -179,7 +179,7 @@ namespace Bit.Core.Services userId = await _stateService.GetActiveUserIdAsync(); } - if (await _keyConnectorService.GetUsesKeyConnector()) + if (!await _userVerificationService.HasMasterPasswordAsync()) { var pinStatus = await GetPinLockTypeAsync(userId); var ephemeralPinSet = await _stateService.GetPinKeyEncryptedUserKeyEphemeralAsync() diff --git a/src/Core/Utilities/ServiceContainer.cs b/src/Core/Utilities/ServiceContainer.cs index d763d23af..39c6aa797 100644 --- a/src/Core/Utilities/ServiceContainer.cs +++ b/src/Core/Utilities/ServiceContainer.cs @@ -55,9 +55,11 @@ namespace Bit.Core.Utilities var policyService = new PolicyService(stateService, organizationService); var keyConnectorService = new KeyConnectorService(stateService, cryptoService, tokenService, apiService, cryptoFunctionService, organizationService); + var userVerificationService = new UserVerificationService(apiService, platformUtilsService, i18nService, + cryptoService, stateService, keyConnectorService); var vaultTimeoutService = new VaultTimeoutService(cryptoService, stateService, platformUtilsService, folderService, cipherService, collectionService, searchService, messagingService, tokenService, - keyConnectorService, + userVerificationService, (extras) => { messagingService.Send("locked", extras); @@ -86,8 +88,6 @@ namespace Bit.Core.Utilities var auditService = new AuditService(cryptoFunctionService, apiService); var environmentService = new EnvironmentService(apiService, stateService, conditionedRunner); var eventService = new EventService(apiService, stateService, organizationService, cipherService); - var userVerificationService = new UserVerificationService(apiService, platformUtilsService, i18nService, - cryptoService); var usernameGenerationService = new UsernameGenerationService(cryptoService, apiService, stateService); var configService = new ConfigService(apiService, stateService, logger); @@ -104,6 +104,8 @@ namespace Bit.Core.Utilities Register("searchService", searchService); Register("policyService", policyService); Register("syncService", syncService); + Register("keyConnectorService", keyConnectorService); + Register(userVerificationService); Register("vaultTimeoutService", vaultTimeoutService); Register("passwordGenerationService", passwordGenerationService); Register("totpService", totpService); @@ -112,8 +114,6 @@ namespace Bit.Core.Utilities Register("auditService", auditService); Register("environmentService", environmentService); Register("eventService", eventService); - Register("keyConnectorService", keyConnectorService); - Register("userVerificationService", userVerificationService); Register(usernameGenerationService); Register(configService); Register(deviceTrustCryptoService); diff --git a/src/iOS.Core/Controllers/BaseLockPasswordViewController.cs b/src/iOS.Core/Controllers/BaseLockPasswordViewController.cs index db5ce6f67..60691b8bb 100644 --- a/src/iOS.Core/Controllers/BaseLockPasswordViewController.cs +++ b/src/iOS.Core/Controllers/BaseLockPasswordViewController.cs @@ -28,14 +28,14 @@ namespace Bit.iOS.Core.Controllers private IStorageService _secureStorageService; private IPlatformUtilsService _platformUtilsService; private IBiometricService _biometricService; - private IKeyConnectorService _keyConnectorService; + private IUserVerificationService _userVerificationService; private IAccountsManager _accountManager; private PinLockType _pinStatus; private bool _pinEnabled; private bool _biometricEnabled; private bool _biometricIntegrityValid = true; private bool _passwordReprompt = false; - private bool _usesKeyConnector; + private bool _hasMasterPassword; private bool _biometricUnlockOnly = false; private bool _checkingPassword; @@ -96,7 +96,7 @@ namespace Bit.iOS.Core.Controllers _secureStorageService = ServiceContainer.Resolve("secureStorageService"); _platformUtilsService = ServiceContainer.Resolve("platformUtilsService"); _biometricService = ServiceContainer.Resolve("biometricService"); - _keyConnectorService = ServiceContainer.Resolve("keyConnectorService"); + _userVerificationService = ServiceContainer.Resolve(); _accountManager = ServiceContainer.Resolve("accountsManager"); // We re-use the lock screen for autofill extension to verify master password @@ -121,15 +121,15 @@ namespace Bit.iOS.Core.Controllers && await _cryptoService.HasEncryptedUserKeyAsync(); _biometricIntegrityValid = await _platformUtilsService.IsBiometricIntegrityValidAsync(BiometricIntegritySourceKey); - _usesKeyConnector = await _keyConnectorService.GetUsesKeyConnector(); - _biometricUnlockOnly = _usesKeyConnector && _biometricEnabled && !_pinEnabled; + _hasMasterPassword = await _userVerificationService.HasMasterPasswordAsync(); + _biometricUnlockOnly = !_hasMasterPassword && _biometricEnabled && !_pinEnabled; } if (_pinEnabled) { BaseNavItem.Title = AppResources.VerifyPIN; } - else if (_usesKeyConnector) + else if (!_hasMasterPassword) { BaseNavItem.Title = AppResources.UnlockVault; } @@ -200,7 +200,7 @@ namespace Bit.iOS.Core.Controllers base.ViewDidAppear(animated); // Users with key connector and without biometric or pin has no MP to unlock with - if (_usesKeyConnector) + if (!_hasMasterPassword) { if (!(_pinEnabled || _biometricEnabled) || (_biometricEnabled && !_biometricIntegrityValid)) diff --git a/src/iOS.Core/Controllers/LockPasswordViewController.cs b/src/iOS.Core/Controllers/LockPasswordViewController.cs index eff86b50e..adb157072 100644 --- a/src/iOS.Core/Controllers/LockPasswordViewController.cs +++ b/src/iOS.Core/Controllers/LockPasswordViewController.cs @@ -29,13 +29,13 @@ namespace Bit.iOS.Core.Controllers private IStorageService _secureStorageService; private IPlatformUtilsService _platformUtilsService; private IBiometricService _biometricService; - private IKeyConnectorService _keyConnectorService; + private IUserVerificationService _userVerificationService; private PinLockType _pinStatus; private bool _pinEnabled; private bool _biometricEnabled; private bool _biometricIntegrityValid = true; private bool _passwordReprompt = false; - private bool _usesKeyConnector; + private bool _hasMasterPassword; private bool _biometricUnlockOnly = false; protected bool autofillExtension = false; @@ -89,7 +89,7 @@ namespace Bit.iOS.Core.Controllers _secureStorageService = ServiceContainer.Resolve("secureStorageService"); _platformUtilsService = ServiceContainer.Resolve("platformUtilsService"); _biometricService = ServiceContainer.Resolve("biometricService"); - _keyConnectorService = ServiceContainer.Resolve("keyConnectorService"); + _userVerificationService = ServiceContainer.Resolve(); // We re-use the lock screen for autofill extension to verify master password // when trying to access protected items. @@ -113,21 +113,21 @@ namespace Bit.iOS.Core.Controllers && await _cryptoService.HasEncryptedUserKeyAsync(); _biometricIntegrityValid = await _platformUtilsService.IsBiometricIntegrityValidAsync(BiometricIntegritySourceKey); - _usesKeyConnector = await _keyConnectorService.GetUsesKeyConnector(); - _biometricUnlockOnly = _usesKeyConnector && _biometricEnabled && !_pinEnabled; + _hasMasterPassword = await _userVerificationService.HasMasterPasswordAsync(); + _biometricUnlockOnly = !_hasMasterPassword && _biometricEnabled && !_pinEnabled; } if (_pinEnabled) { BaseNavItem.Title = AppResources.VerifyPIN; } - else if (_usesKeyConnector) + else if (_hasMasterPassword) { - BaseNavItem.Title = AppResources.UnlockVault; + BaseNavItem.Title = AppResources.VerifyMasterPassword; } else { - BaseNavItem.Title = AppResources.VerifyMasterPassword; + BaseNavItem.Title = AppResources.UnlockVault; } BaseCancelButton.Title = AppResources.Cancel; @@ -186,8 +186,8 @@ namespace Bit.iOS.Core.Controllers { base.ViewDidAppear(animated); - // Users with key connector and without biometric or pin has no MP to unlock with - if (_usesKeyConnector) + // Users without MP and without biometric or pin need SSO + if (!_hasMasterPassword) { if (!(_pinEnabled || _biometricEnabled) || (_biometricEnabled && !_biometricIntegrityValid)) diff --git a/src/iOS.Core/Utilities/iOSCoreHelpers.cs b/src/iOS.Core/Utilities/iOSCoreHelpers.cs index 09c558134..fa76caccd 100644 --- a/src/iOS.Core/Utilities/iOSCoreHelpers.cs +++ b/src/iOS.Core/Utilities/iOSCoreHelpers.cs @@ -247,7 +247,8 @@ namespace Bit.iOS.Core.Utilities var verificationActionsFlowHelper = new VerificationActionsFlowHelper( ServiceContainer.Resolve("keyConnectorService"), ServiceContainer.Resolve("passwordRepromptService"), - ServiceContainer.Resolve("cryptoService")); + ServiceContainer.Resolve("cryptoService"), + ServiceContainer.Resolve()); ServiceContainer.Register("verificationActionsFlowHelper", verificationActionsFlowHelper); if (postBootstrapFunc != null)