1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-12 14:23:26 +00:00

Fix for deadlock in iOS autofill & share extensions (#960)

This commit is contained in:
Matt Portune
2020-06-07 00:15:51 -04:00
committed by GitHub
parent fd1941cc3e
commit 473e93ea16
3 changed files with 25 additions and 24 deletions

View File

@@ -41,7 +41,7 @@ namespace Bit.iOS.Autofill
};
}
public override void PrepareCredentialList(ASCredentialServiceIdentifier[] serviceIdentifiers)
public override async void PrepareCredentialList(ASCredentialServiceIdentifier[] serviceIdentifiers)
{
InitAppIfNeeded();
_context.ServiceIdentifiers = serviceIdentifiers;
@@ -54,11 +54,11 @@ namespace Bit.iOS.Autofill
}
_context.UrlString = uri;
}
if (!IsAuthed())
if (! await IsAuthed())
{
LaunchLoginFlow();
}
else if (IsLocked())
else if (await IsLocked())
{
PerformSegue("lockPasswordSegue", this);
}
@@ -75,10 +75,10 @@ namespace Bit.iOS.Autofill
}
}
public override void ProvideCredentialWithoutUserInteraction(ASPasswordCredentialIdentity credentialIdentity)
public override async void ProvideCredentialWithoutUserInteraction(ASPasswordCredentialIdentity credentialIdentity)
{
InitAppIfNeeded();
if (!IsAuthed() || IsLocked())
if (! await IsAuthed() || await IsLocked())
{
var err = new NSError(new NSString("ASExtensionErrorDomain"),
Convert.ToInt32(ASExtensionErrorCode.UserInteractionRequired), null);
@@ -86,13 +86,13 @@ namespace Bit.iOS.Autofill
return;
}
_context.CredentialIdentity = credentialIdentity;
ProvideCredentialAsync().GetAwaiter().GetResult();
await ProvideCredentialAsync();
}
public override void PrepareInterfaceToProvideCredential(ASPasswordCredentialIdentity credentialIdentity)
public override async void PrepareInterfaceToProvideCredential(ASPasswordCredentialIdentity credentialIdentity)
{
InitAppIfNeeded();
if (!IsAuthed())
if (! await IsAuthed())
{
LaunchLoginFlow();
return;
@@ -101,11 +101,11 @@ namespace Bit.iOS.Autofill
CheckLock(async () => await ProvideCredentialAsync());
}
public override void PrepareInterfaceForExtensionConfiguration()
public override async void PrepareInterfaceForExtensionConfiguration()
{
InitAppIfNeeded();
_context.Configuring = true;
if (!IsAuthed())
if (! await IsAuthed())
{
LaunchLoginFlow();
return;
@@ -237,9 +237,9 @@ namespace Bit.iOS.Autofill
CompleteRequest(decCipher.Id, decCipher.Login.Username, decCipher.Login.Password, totpCode);
}
private void CheckLock(Action notLockedAction)
private async void CheckLock(Action notLockedAction)
{
if (IsLocked())
if (await IsLocked())
{
PerformSegue("lockPasswordSegue", this);
}
@@ -249,16 +249,16 @@ namespace Bit.iOS.Autofill
}
}
private bool IsLocked()
private Task<bool> IsLocked()
{
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
return vaultTimeoutService.IsLockedAsync().GetAwaiter().GetResult();
return vaultTimeoutService.IsLockedAsync();
}
private bool IsAuthed()
private Task<bool> IsAuthed()
{
var userService = ServiceContainer.Resolve<IUserService>("userService");
return userService.IsAuthenticatedAsync().GetAwaiter().GetResult();
return userService.IsAuthenticatedAsync();
}
private void InitApp()