1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-20 09:23:50 +00:00

PM-7385 Fix IFido2MakeCredentialConfirmationUserInterface resolve and usage to be constrained to Android. (#3164)

This commit is contained in:
Federico Maccaroni
2024-04-17 09:05:46 -03:00
committed by GitHub
parent 5a4a54f4af
commit 4eb608ec11
6 changed files with 35 additions and 12 deletions

View File

@@ -20,7 +20,9 @@ namespace Bit.App.Utilities.AccountManagement
private readonly IMessagingService _messagingService;
private readonly IWatchDeviceService _watchDeviceService;
private readonly IConditionedAwaiterManager _conditionedAwaiterManager;
private LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _userVerificationMediatorService = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
#if ANDROID
private LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _fido2MakeCredentialConfirmationUserInterface = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
#endif
Func<AppOptions> _getOptionsFunc;
private IAccountsManagerHost _accountsManagerHost;
@@ -101,12 +103,14 @@ namespace Bit.App.Utilities.AccountManagement
{
_accountsManagerHost.Navigate(NavigationTarget.AddEditCipher);
}
else if (_userVerificationMediatorService.Value.IsConfirmingNewCredential)
#if ANDROID
else if (_fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential)
{
// If we are already confirming a credential we don't need to navigate again.
// This could happen when switching accounts for example.
return;
}
#endif
else if (Options.FromFido2Framework)
{
var deviceActionService = Bit.Core.Utilities.ServiceContainer.Resolve<IDeviceActionService>();

View File

@@ -432,8 +432,10 @@ namespace Bit.App.Utilities
// this is called after login in or unlocking so we can assume the vault has been unlocked in this transaction here.
appOptions.HasUnlockedInThisTransaction = true;
var userVerificationMediatorService = ServiceContainer.Resolve<IFido2MakeCredentialConfirmationUserInterface>();
userVerificationMediatorService.SetCheckHasVaultBeenUnlockedInThisTransaction(() => appOptions?.HasUnlockedInThisTransaction == true);
#if ANDROID
var fido2MakeCredentialConfirmationUserInterface = ServiceContainer.Resolve<IFido2MakeCredentialConfirmationUserInterface>();
fido2MakeCredentialConfirmationUserInterface.SetCheckHasVaultBeenUnlockedInThisTransaction(() => appOptions?.HasUnlockedInThisTransaction == true);
#endif
if (appOptions.FromAutofillFramework && appOptions.SaveType.HasValue)
{
@@ -441,13 +443,15 @@ namespace Bit.App.Utilities
return true;
}
#if ANDROID
// If we are waiting for an unlock vault we don't want to trigger 'ExecuteFido2CredentialActionAsync' again,
// as it's already running. We just need to 'ConfirmUnlockVault' on the 'userVerificationMediatorService'.
if (userVerificationMediatorService.IsWaitingUnlockVault)
if (fido2MakeCredentialConfirmationUserInterface.IsWaitingUnlockVault)
{
userVerificationMediatorService.ConfirmVaultUnlocked();
fido2MakeCredentialConfirmationUserInterface.ConfirmVaultUnlocked();
return true;
}
#endif
if (appOptions.FromFido2Framework && !string.IsNullOrWhiteSpace(appOptions.Fido2CredentialAction))
{